﻿using CentralVacuum.Common;
using CentralVacuum.Communication;
using CentralVacuum.Froms;
using CentralVacuum.Keyboard;
using CentralVacuum.Models;
using CentralVacuum.Mqtt;
using CentralVacuum.Pages;
using CentralVacuum.Properties;
using CentralVacuum.SqlSugarService;
using HslCommunication.LogNet;
using Microsoft.Reporting.WinForms;
using QRCoder;
using SharpGL;
using SqlSugar;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Entity.Infrastructure.Interception;
using System.Data.SQLite;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web.Compilation;
using System.Windows.Forms;

namespace CentralVacuum
{
    public partial class FCustomGlobal : UIForm
    {
        private AlarmLogs ralarmlog;

        private List<PLog> page = new List<PLog>();
        private List<PLog> reportList = new List<PLog>();
        //SQLiteCommand m_command;
        private SqlSugarScope db = SqlSugarHelper.Db;
        private bool LicenseStatus = false;//激活许可证
        private int gButtonFlag = 0, gItemIndex = -1;
        private int totalCount = 0;
        private int loginFlag = 0;

        private float[,] arrSource = new float [450,6];//根据time1的周期100ms存储45S的数据(压力温度等)
        private float[] dwsSource = new float [50];//存储DWS实际密度

        //int uiPagination_pageIndex = 1;
        private string ActivationStatus = "", original = "";
        private int Runningtime = 0;//运行时间
        R_TRIG rTrig0 = new R_TRIG();
        R_TRIG rTrig1 = new R_TRIG();
        R_TRIG rTrig2 = new R_TRIG();
        R_TRIG rTrig3 = new R_TRIG();
        R_TRIG rTrig4 = new R_TRIG();
        R_TRIG rTrig5 = new R_TRIG();
        R_TRIG rTrig6 = new R_TRIG();
        R_TRIG rTrig7 = new R_TRIG();
        R_TRIG rTrig8 = new R_TRIG();
        R_TRIG rTrig9 = new R_TRIG();
        R_TRIG rTrig10 = new R_TRIG();
        R_TRIG rTrig11 = new R_TRIG();
        R_TRIG rTrig12 = new R_TRIG();
        R_TRIG rTrig13 = new R_TRIG();
        R_TRIG rTrig14 = new R_TRIG();
        R_TRIG rTrig15 = new R_TRIG();
        R_TRIG rTrig16 = new R_TRIG();
        R_TRIG rTrig17 = new R_TRIG();
        R_TRIG rTrig18 = new R_TRIG();
        R_TRIG rTrig19 = new R_TRIG();
        R_TRIG rTrig20 = new R_TRIG();
        R_TRIG rTrig21 = new R_TRIG();

        R_TRIG rTrig22 = new R_TRIG();
        R_TRIG rTrig23 = new R_TRIG();
        R_TRIG rTrig24 = new R_TRIG();
        R_TRIG rTrig25 = new R_TRIG();
        R_TRIG rTrig26 = new R_TRIG();
        R_TRIG rTrig27 = new R_TRIG();
        R_TRIG rTrig28 = new R_TRIG();
        R_TRIG rTrig29 = new R_TRIG();
        R_TRIG rTrig30 = new R_TRIG();
        R_TRIG rTrig31 = new R_TRIG();
        R_TRIG rTrig32 = new R_TRIG();

        public FCustomGlobal()
        {
            InitializeComponent();
            //autoScale.SetContainer(this);
            //uiPagination_pageIndex = this.uiPagination1.ActivePage;//初始化日志
            uiStyleManager1.Style = Settings.Default.UIStyle;//初始化主题
            uiMarkLabel4.Text = uiTabControl1.SelectedTab.Text;//切换语言后，再次启动改变
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //文件初始化
            if (!backgroundWorker6.IsBusy)
            {
                this.backgroundWorker6.RunWorkerAsync();//文件初始化
            }
            /*
            //顺序加载
            if (!ExistPage(1000))
            {
                //AddPage(new FPageMain());
            }
            if (!ExistPage(1001))
            {
                //AddPage(new FPageSetting());
            }
            if (!ExistPage(1002))
            {
                //AddPage(new FPageSystem());
            }
            */
        }

        private void FCustomGlobal_SizeChanged(object sender, EventArgs e)
        {
            
        }

        /// <summary>
        /// 读取plc的参数到UI显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            uiLabel5.Text = DateTime.Now.ToString();//系统时间显示
            if (LicenseStatus == false)//许可证未激活
            {
                if (Runningtime >= 36000)//未授权情况下,时间到停止运行
                {
                    HslMelsecMCBinary.WriteBool("M2002", false);//关闭自动功能
                    HslMelsecMCBinary.WriteBool("M2001", false);//关闭上料功能
                    Global.LogNet.WriteError(this.Name.ToString(), "许可证未激活,退出应用程序!");
                    if (Settings.Default.Language == 0)//中文
                    {
                        UIMessageDialog.ShowMessageDialog("许可证未激活,退出应用程序!", UILocalize.ErrorTitle, false, UIStyle.Red);
                    }
                    else if (Settings.Default.Language == 1)//英文
                    {
                        UIMessageDialog.ShowMessageDialog("License is not active, exit the application!", UILocalize.ErrorTitle, false, UIStyle.Red);
                    }
                    Environment.Exit(0);//退出应用程序
                }
                else
                {
                    Runningtime += 1;//运行时间100ms
                }
            }
            //登录权限后显示画面
            if (Global.IsLogin >= 1)
            {
                if (loginFlag == 1)
                {
                    uiTabControlMenu1.TabPages.Add(tabPage13);//报警限制
                    uiTabControlMenu1.TabPages.Add(tabPage14);//标定参数
                    uiTabControlMenu1.TabPages.Add(tabPage12);//PID参数
                    uiTabControlMenu1.TabPages.Add(tabPage15);//模块配置
                    uiStyleManager1.Style = Settings.Default.UIStyle;//主题刷新
                    loginFlag = 0;
                }
            }
            else
            {
                if (loginFlag == 0)
                {
                    uiTabControlMenu1.TabPages.Remove(tabPage13);//报警限制
                    uiTabControlMenu1.TabPages.Remove(tabPage14);//标定参数
                    uiTabControlMenu1.TabPages.Remove(tabPage12);//PID参数
                    uiTabControlMenu1.TabPages.Remove(tabPage15);//模块配置
                    uiStyleManager1.Style = Settings.Default.UIStyle;//主题刷新
                    loginFlag = 1;
                }
            }
            
            //********************
            //*****global画面*******
            //********************
            if (gButtonFlag == 1) //这一个判断很关键,必须加上!
                return;

            uiBreadcrumb1.ItemIndex = gItemIndex;//流程步骤显示
            if (gItemIndex == 1)
            {
                if (Global.rData.D2300 > Global.rData.D1110)
                {
                    gItemIndex = 2;//订单确认
                }
            }
            else if (gItemIndex == 2)
            {
                if (Global.rData.D3300 == 1)
                {
                    gItemIndex = 3;//自动按钮
                }
            }
            else if (gItemIndex == 3)
            {
                if (Global.rData.D3300 == 0)
                {
                    gItemIndex = 2;//订单确认
                }
                else if (Global.rData.D3300 == 2)
                {
                    gItemIndex = 4;//生产过程
                }
            }
            else if (gItemIndex == 4)
            {
                if (Global.rData.D2300 <= Global.rData.D1110)
                {
                    gItemIndex = 5;//订单完成
                }
            }
            else if (gItemIndex == 5)
            {
                if (Global.rData.D2300 > Global.rData.D1110)
                {
                    gItemIndex = 2;//订单完成
                }
            }
            
            if (Global.rData.gS0[31] == true)//机器锁机
            {
                uiScrollingText1.Active = true;
                uiScrollingText1.ForeColor = Color.Red;//报警颜色
                if (Settings.Default.Language == 0)  // 中文
                {
                    uiScrollingText1.Text = "设备已锁定,请联系制造商!!!";
                }
                else if (Settings.Default.Language == 1) // 英文
                {   
                    uiScrollingText1.Text = "Machine is locked, contact manufacturer!!!";
                }
                //Global.LogNet.WriteError(this.Name.ToString(), "机器已锁定,请联系制造商!!!");
            }
            else if ((Global.rData.D2222 + 2000 > Global.rData.D2334) && Global.rData.D2334 != 0)//锁机模数提示
            {
                uint num = Global.rData.D2334 - Global.rData.D2222;
                uiScrollingText1.Active = true;
                uiScrollingText1.ForeColor = Color.Red;//报警颜色
                if (Settings.Default.Language == 0)  // 中文
                {
                    uiScrollingText1.Text = "剩余生产"+ num.ToString() + "模后锁定设备,请联系制造商!!!";
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    uiScrollingText1.Text = "Lock device after "+ num.ToString() + " cycles, contact manufacturer!!!";
                }
            }
            else if (Global.rData.gS0[13] == true)//报警窗口
            {
                uiScrollingText1.Active = true;
                uiScrollingText1.ForeColor = Color.Red;//报警颜色
            }
            else
            {
                uiScrollingText1.Active = false;
                uiScrollingText1.ForeColor = uiScrollingText1.RectColor;//边框颜色
                if (Settings.Default.Language == 0)  // 中文
                {
                    uiScrollingText1.Text = "正常运行中!!!";
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    uiScrollingText1.Text = "Running!!!";
                }
            }
            //检测电控柜电源突然断开UPS工作。
            rTrig13.CLK = Global.rData.gS1200[37];
            if (rTrig13.Q)
            {
                HslMelsecMCBinary.WriteBool("M2002", false);//关闭自动功能
                HslMelsecMCBinary.WriteBool("M2001", false);//关闭上料功能
                Global.LogNet.WriteFatal(this.Name.ToString(), "UPS电源工作!");
                Process.Start("shutdown.exe", "-s -t 1");//关机电脑
                Environment.Exit(0);//关闭程序
            }


            //********************
            //*****主画面*******
            //********************
            #region *******曲线显示部分***********

            Array.Copy(arrSource, 0, arrSource, arrSource.GetLength(1), (arrSource.GetLength(0) - 1) * arrSource.GetLength(1));//一维右移动,二维保持不变.

            arrSource[0, 5] = Global.rData.D1004;//实际比例阀开度
            arrSource[0, 4] = Global.rData.D1006;//pid输出开度

            arrSource[0, 3] = Global.rData.D1014;//实际温度
            arrSource[0, 2] = Global.rData.D2010;//设定温度
            arrSource[0, 1] = Global.rData.D1018;//实际压力
            arrSource[0, 0] = Global.rData.D2008;//设定压力

            #endregion

            #region *******数据显示部分***********
            uiLabel1.Text = Global.rData.D1026.ToString("0.00") + "Bar";//主蒸汽压力
            uiAnalogMeter2.Value = Global.rData.D1026;
            uiLabel2.Text = Global.rData.D1024.ToString("0.00") + "Bar";//空气压力
            uiAnalogMeter4.Value = Global.rData.D1024;
            uiLabel3.Text = Global.rData.D1006.ToString("0.0") + "%";//PID跟踪
            uiAnalogMeter3.Value = Convert.ToDouble(Global.rData.D1006);
            uiTextBox22.Text = ControlAttribute.TextBoxRead(uiTextBox22, Global.rData.D1042.ToString()) + "A";//主轴电流
            uiTextBox8.Text = ControlAttribute.TextBoxRead(uiTextBox8, Global.rData.D1012.ToString()) + "℃";//桶内温度
            uiTextBox9.Text = ControlAttribute.TextBoxRead(uiTextBox9, Global.rData.D1010.ToString()) + "Bar";//桶内压力
            uiTextBox10.Text = ControlAttribute.TextBoxRead(uiTextBox10, (Convert.ToSingle(Global.rData.D1108)/100).ToString()) + "S";//加热时间
            uiTextBox4.Text = ControlAttribute.TextBoxRead(uiTextBox4, Global.rData.D1008.ToString());//实际重量
            uiTextBox7.Text = ControlAttribute.TextBoxRead(uiTextBox7, Global.rData.D1018.ToString());//实际压力
            uiTextBox5.Text = ControlAttribute.TextBoxRead(uiTextBox5, Global.rData.D1014.ToString());//实际温度
            uiTextBox24.Text = ControlAttribute.TextBoxRead(uiTextBox24, Global.rData.D1020.ToString());//实际排气
            uiLabel10.Text = (Convert.ToSingle(Global.rData.D1106) / 100).ToString("0.0");//实际时间
            uiLabel7.Text = (Convert.ToSingle(Global.rData.D1104)/ 100).ToString("0.0");//设定时间
            uiLabel14.Text = (Convert.ToSingle(Global.rData.D1100)/ 100).ToString("0.0");//总周期
            uiLabel15.Text = (Convert.ToSingle(Global.rData.D1102)/ 100).ToString("0.0");//运行周期
            uiTextBox11.Text = ControlAttribute.TextBoxRead(uiTextBox11, Global.rData.D1044.ToString()) + "g";//dws重量
            uiTextBox26.Text = ControlAttribute.TextBoxRead(uiTextBox26, Global.rData.D1022.ToString());//平均密度
            uiTextBox25.Text = ControlAttribute.TextBoxRead(uiTextBox25, Global.rData.D1016.ToString());//实际密度
            uiTextBox28.Text = ControlAttribute.TextBoxRead(uiTextBox28, Global.rData.D1030.ToString());//最大密度
            uiTextBox27.Text = ControlAttribute.TextBoxRead(uiTextBox27, Global.rData.D1032.ToString());//最小密度

            //uiTextBox1.Text = Global.rData.D2000.ToString();//设定重量
            uiTextBox1.Text = ControlAttribute.TextBoxRead(uiTextBox1, Global.rData.D2000.ToString());//设定重量
            uiTextBox2.Text = ControlAttribute.TextBoxRead(uiTextBox2, Global.rData.D2010.ToString());//设置温度
            uiTextBox6.Text = ControlAttribute.TextBoxRead(uiTextBox6, Global.rData.D2008.ToString());//设定压力
            uiTextBox23.Text = ControlAttribute.TextBoxRead(uiTextBox23, Global.rData.D2050.ToString());//设定排气

            //主画面显示
            if (Settings.Default.Language == 0)  // 中文
            {
                uiLabel488.Text = "配方名: " + uiTextBox15.Text + "-" + uiTextBox16.Text + "g";//eps品牌（主画面显示）
                uiLabel483.Text = "EPS品牌: " + uiTextBox15.Text;//eps品牌（主画面显示）
                uiLabel484.Text = "发泡密度: " + uiTextBox16.Text + "kg/m³";//发泡密度（主画面显示）
                uiLabel485.Text = "加热模式: " + uiComboBox32.Text;//加热模式（主画面显示）
                uiLabel486.Text = "加热检测: " + uiComboBox2.Text;//加热检测（主画面显示）
                uiLabel487.Text = "发料工艺: " + uiComboBox3.Text;//发料工艺（主画面显示）
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                uiLabel488.Text = "Formula: " + uiTextBox15.Text + "-" + uiTextBox16.Text + "g";//eps品牌（主画面显示）
                uiLabel483.Text = "EPS Brand: " + uiTextBox15.Text;//eps品牌（主画面显示）
                uiLabel484.Text = "EPS Density: " + uiTextBox16.Text + "kg/m³";//发泡密度（主画面显示）
                uiLabel485.Text = "Heating Mode: " + uiComboBox32.Text;//加热模式（主画面显示）
                uiLabel486.Text = "EPS Detection: " + uiComboBox2.Text;//加热检测（主画面显示）
                uiLabel487.Text = "EPS Process: " + uiComboBox3.Text;//发料工艺（主画面显示）
            }
            
            #endregion

            #region **************主画面动态开关显示图***************
            uiLight1.State = (Global.rData.gS1200[10] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight3.State = (Global.rData.gS1200[11] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight73.State = (Global.rData.gS1200[35] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight2.State = (Global.rData.gS1000[35] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight4.State = (Global.rData.gS1000[36] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight6.State = (Global.rData.gS1000[33] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight5.State = (Global.rData.gS1000[34] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight74.State = (Global.rData.gS1000[20] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight8.State = (Global.rData.gS1000[22] == false) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight7.State = (Global.rData.gS1000[6] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight22.State = (Global.rData.gS1000[10] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight21.State = (Global.rData.gS1000[12] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight20.State = (Global.rData.gS1000[37] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight18.State = (Global.rData.gS1200[12] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight19.State = (Global.rData.gS1200[13] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight9.State = (Global.rData.gM1000[0] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight17.State = (Global.rData.gS1000[21] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight25.State = (Global.rData.gS1000[24] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight23.State = (Global.rData.gS1200[15] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight24.State = (Global.rData.gS1200[14] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight13.State = (Global.rData.gS1000[32] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight10.State = (Global.rData.gS1000[13] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight11.State = (Global.rData.gS1000[13] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight75.State = (Global.rData.gS1000[13] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight12.State = (Global.rData.gS1000[14] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight14.State = (Global.rData.gS1000[23] == false) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight15.State = (Global.rData.gS1000[30] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight16.State = (Global.rData.gS1000[31] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight27.State = (Global.rData.gS1000[75] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight28.State = (Global.rData.gS1000[60] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight29.State = (Global.rData.gS1000[61] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight30.State = (Global.rData.gS1000[55] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight31.State = (Global.rData.gS1000[56] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight32.State = (Global.rData.gS1000[52] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight26.State = (Global.rData.gS1200[27] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            #endregion

            #region ************主画面电机动态图************
            if (Global.rData.D3312 == 1)
            {
                hslBlower1.MoveSpeed = Convert.ToSingle(-1);
                hslBlower1.Color3 = Color.MediumSpringGreen;
                hslPipeLine1.PipeLineActive = true;
                hslPipeLine2.PipeLineActive = true;
                hslPipeLine3.PipeLineActive = true;
            }
            else if (Global.rData.D3312 == 2)
            {
                hslBlower1.MoveSpeed = 0;
                hslBlower1.Color3 = Color.Yellow;
                hslPipeLine1.PipeLineActive = false;
                hslPipeLine2.PipeLineActive = false;
                hslPipeLine3.PipeLineActive = false;
            }
            else
            {
                hslBlower1.MoveSpeed = 0;
                hslBlower1.Color3 = Color.Gainsboro;
                hslPipeLine1.PipeLineActive = false;
                hslPipeLine2.PipeLineActive = false;
                hslPipeLine3.PipeLineActive = false;
            }
            hslBlower2.MoveSpeed = (Global.rData.D3311 == 1) ? Convert.ToSingle(1) : 0;
            hslBlower2.Color3 = (Global.rData.D3311 == 1) ? Color.MediumSpringGreen : Color.Gainsboro;
            hslBlower3.MoveSpeed = (Global.rData.D3313 == 1) ? Convert.ToSingle(1) : 0;
            hslBlower3.Color3 = (Global.rData.D3313 == 1) ? Color.MediumSpringGreen : Color.Gainsboro;
            hslBlower4.MoveSpeed = (Global.rData.D3315 == 1) ? Convert.ToSingle(-1) : 0;
            hslBlower4.Color3 = (Global.rData.D3315 == 1) ? Color.MediumSpringGreen : Color.Gainsboro;
            hslPumpOne1.MoveSpeed = (Global.rData.D3314 == 1) ? Convert.ToSingle(-1) : 0;
            hslPumpOne1.Color4 = (Global.rData.D3314 == 1) ? Color.MediumSpringGreen : Color.Gainsboro;
            hslPumpOne2.MoveSpeed = (Global.rData.D3307 == 1) ? Convert.ToSingle(-1) : 0;
            hslPumpOne2.Color4 = (Global.rData.D3307 == 1) ? Color.MediumSpringGreen : Color.Gainsboro;
            hslCoolFan1.MoveSpeed = (Global.rData.D3306 == 1) ? Convert.ToSingle(0.5) : 0;
            hslCoolFan1.CenterColor = (Global.rData.D3306 == 1) ? Color.MediumSpringGreen : Color.Gray;
            hslCoolFan2.MoveSpeed = (Global.rData.D3309 == 1) ? Convert.ToSingle(0.5) : 0;
            hslCoolFan2.CenterColor = (Global.rData.D3309 == 1) ? Color.MediumSpringGreen : Color.Gray;
            hslCoolFan3.MoveSpeed = (Global.rData.D3310 == 1) ? Convert.ToSingle(0.5) : 0;
            hslCoolFan3.CenterColor = (Global.rData.D3310 == 1) ? Color.MediumSpringGreen : Color.Gray;
            #endregion

            #region **************主画面操作面板***************
            if (Global.rData.D3300 == 1)
            {
                uiHeaderButton2.Image = Resources.Auto1;
            }
            else if (Global.rData.D3300 == 2)
            {
                uiHeaderButton2.Image = Resources.Auto2;
            }
            else
            {
                uiHeaderButton2.Image = Resources.Auto0;
            }
            if (Global.rData.D3301 == 1)
            {
                uiHeaderButton1.Image = Resources.Feed1;
            }
            else if (Global.rData.D3301 == 2)
            {
                uiHeaderButton1.Image = Resources.Feed2;
            }
            else
            {
                uiHeaderButton1.Image = Resources.Feed0;
            }
            if (Global.rData.D3302 == 1)
            {
                uiHeaderButton4.Image = Resources.Weight1;
            }
            else if (Global.rData.D3302 == 2)
            {
                uiHeaderButton4.Image = Resources.Weight2;
            }
            else
            {
                uiHeaderButton4.Image = Resources.Weight0;
            }
            if (Global.rData.D3303 == 1)
            {
                uiHeaderButton3.Image = Resources.FeedUp1;
            }
            else if (Global.rData.D3303 == 2)
            {
                uiHeaderButton3.Image = Resources.FeedUp2;
            }
            else
            {
                uiHeaderButton3.Image = Resources.FeedUp0;
            }
            if (Global.rData.D3305 == 1)
            {
                uiHeaderButton5.Image = Resources.Dws1;
            }
            else if (Global.rData.D3305 == 2)
            {
                uiHeaderButton5.Image = Resources.Dws2;
            }
            else
            {
                uiHeaderButton5.Image = Resources.Dws0;
            }
            if (Global.rData.D3316 == 1)
            {
                uiHeaderButton6.Image = Resources.DwsBack1;
            }
            else if (Global.rData.D3316 == 2)
            {
                uiHeaderButton6.Image = Resources.DwsBack2;
            }
            else
            {
                uiHeaderButton6.Image = Resources.DwsBack0;
            }
            if (Global.rData.D3304 == 1)
            {
                uiHeaderButton10.Image = Resources.Clean1;
            }
            else if (Global.rData.D3304 == 2)
            {
                uiHeaderButton10.Image = Resources.Clean2;
            }
            else
            {
                uiHeaderButton10.Image = Resources.Clean0;
            }
            #endregion

            #region *******控件隐藏部分***********
            //uiHeaderButton3.Enabled = Global.rData.gS0[31] == false;

            uiTextBox4.Visible = Global.rData.D2622 == 1;
            uiTextBox1.Visible = Global.rData.D2622 == 1;
            uiLabel18.Visible = Global.rData.D2622 == 1;

            uiTextBox5.Visible = Global.rData.D2228 != 0;
            uiTextBox2.Visible = Global.rData.D2228 != 0;
            uiLabel19.Visible = Global.rData.D2228 != 0;

            uiTextBox7.Visible = Global.rData.D2230 != 0;
            uiTextBox6.Visible = Global.rData.D2230 != 0;
            uiLabel20.Visible = Global.rData.D2230 != 0;

            uiTextBox8.Visible = Global.rData.D2224 != 0;
            uiTextBox9.Visible = Global.rData.D2226 != 0;

            uiTextBox22.Visible = Global.rData.D2242 != 0;

            uiTextBox24.Visible = Global.rData.D2248 != 0;
            uiTextBox23.Visible = Global.rData.D2248 != 0;
            uiLabel24.Visible = Global.rData.D2248 != 0;

            uiTextBox25.Visible = Global.rData.D2619 == 1;
            uiTextBox26.Visible = Global.rData.D2619 == 1;
            uiTextBox27.Visible = Global.rData.D2619 == 1;
            uiTextBox28.Visible = Global.rData.D2619 == 1;
            uiLabel25.Visible = Global.rData.D2619 == 1;
            uiLabel26.Visible = Global.rData.D2619 == 1;
            uiLabel27.Visible = Global.rData.D2619 == 1;
            uiLabel28.Visible = Global.rData.D2619 == 1;
            uiTextBox11.Visible = Global.rData.D2619 == 1;
            /*
            hslBlower4.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslPipeLine29.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight27.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight32.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslClassifier3.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight26.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslPipeLine28.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight28.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslPipeLine30.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslArrow10.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight29.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslPipeLine31.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslPipeLine34.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslPipeLine33.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight30.Visible = (Global.rData.D2619 == 1) ? true : false;
            uiLight31.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslArrow11.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslArrow12.Visible = (Global.rData.D2619 == 1) ? true : false;
            hslWaterBox2.Visible = (Global.rData.D2619 == 1) ? true : false;
            */

            uiMarkLabel1.Visible = Global.rData.D2238 != 0;
            uiLabel1.Visible = Global.rData.D2238 != 0;
            uiAnalogMeter2.Visible = Global.rData.D2238 != 0;

            uiMarkLabel2.Visible = Global.rData.D2240 != 0;
            uiLabel2.Visible = Global.rData.D2240 != 0;
            uiAnalogMeter4.Visible = Global.rData.D2240 != 0;

            uiMarkLabel3.Visible = Global.rData.D2244 != 0;
            uiLabel3.Visible = Global.rData.D2244 != 0;
            uiAnalogMeter3.Visible = Global.rData.D2244 != 0;
            #endregion
            //********流程显示**********
            switch (Global.rData.D1400)
            {
                case 0:
                    uiLabel12.Text = "-----------------";
                    break;
                case 1:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "准备";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Ready";
                    }
                    break;
                case 2:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "稳定";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Stable";
                    }
                    break;
                case 3:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "减压";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Pressure relief";
                    }
                    break;
                case 4:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "放料传输锁定";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Discharge lock";
                    }
                    break;
                case 5:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "放料传输开启";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Discharge open";
                    }
                    break;
                case 6:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "放料传输";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Dischargeing";
                    }
                    break;
                case 7:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "放料传输关闭";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Door closing";
                    }
                    break;
                case 8:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "填充入料";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Feeding";
                    }
                    break;
                case 9:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "填充入料延时";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Feeding delay";
                    }
                    break;
                case 10:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "蒸汽加热";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Steamming";
                    }
                    break;
                case 11:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "蒸汽停止";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Steam stop";
                    }
                    break;
                case 12:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "生产结束";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "End";
                    }
                    break;
                case 13:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "等待填充入料";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Waiting for fill";
                    }
                    break;
                case 14:
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        uiLabel12.Text = "等待填充入料";
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        uiLabel12.Text = "Waiting for fill";
                    }
                    break;
                default:
                    break; //必须有
            }
            //********************
            //*****订单管理*******
            //********************
            #region *******数据显示部分***********
            uiTextBox13.Text = ControlAttribute.TextBoxRead(uiTextBox13, Global.rData.D2028.ToString());//原料生产总重量
            uiTextBox14.Text = ControlAttribute.TextBoxRead(uiTextBox14, Global.rData.D2222.ToString());//原料生产总模数
            uiTextBox3.Text = ControlAttribute.TextBoxRead(uiTextBox3, Global.rData.D1036.ToString());//订单生产总重量
            uiTextBox12.Text = ControlAttribute.TextBoxRead(uiTextBox12, Global.rData.D2012.ToString());//订单生产当前重量
            uiTextBox17.Text = ControlAttribute.TextBoxRead(uiTextBox17, Global.rData.D1110.ToString());//订单生产当前模数
            uiTextBox18.Text = ControlAttribute.TextBoxRead(uiTextBox18, Global.rData.D2300.ToString());//订单设定模数
            uiTextBox19.Text = ControlAttribute.TextBoxRead(uiTextBox19, Global.rData.D2600.ToString());//预热模数

            uiTextBox15.Text = Global.rData.D1500.ToString();//EPS品牌
            uiTextBox16.Text = ControlAttribute.TextBoxRead(uiTextBox16, Global.rData.D1046.ToString());//发泡密度
            uiTextBox20.Text = ControlAttribute.TextBoxRead(uiTextBox20, (Convert.ToSingle(Global.rData.D2204) / 100).ToString());//最大加热时间
            uiTextBox21.Text = ControlAttribute.TextBoxRead(uiTextBox21, (Convert.ToSingle(Global.rData.D2326) / 100).ToString());//二次发料计量时间



            #endregion
            //********************
            //*****配方管理*******
            //********************
            #region *******控件隐藏部分***********
            uiLabel32.Visible = Global.rData.D2606 == 1;
            uiTextBox20.Visible = Global.rData.D2606 == 1;
            uiLabel40.Visible = Global.rData.D2606 == 1;

            uiLabel424.Visible = Global.rData.D2607 == 1;
            uiTextBox21.Visible = Global.rData.D2607 == 1;
            uiLabel37.Visible = Global.rData.D2607 == 1;

            uiComboBox3.Visible = Global.rData.D2623 == 1;
            uiLabel49.Visible = Global.rData.D2623 == 1;
            #endregion

            //********************
            //*****参数管理*******
            //********************
            #region *******数据显示部分***********
            //*************流程参数**************
            uiTextBox29.Text = ControlAttribute.TextBoxRead(uiTextBox29, (Convert.ToSingle(Global.rData.D2316) / 100).ToString());//稳定时间
            uiTextBox30.Text = ControlAttribute.TextBoxRead(uiTextBox30, (Convert.ToSingle(Global.rData.D2318) / 100).ToString());//减压时间
            uiTextBox31.Text = ControlAttribute.TextBoxRead(uiTextBox31, (Convert.ToSingle(Global.rData.D2206) / 100).ToString());//出料时间
            uiTextBox32.Text = ControlAttribute.TextBoxRead(uiTextBox32, (Convert.ToSingle(Global.rData.D2208) / 100).ToString());//关门时间
            uiTextBox33.Text = ControlAttribute.TextBoxRead(uiTextBox33, (Convert.ToSingle(Global.rData.D2210) / 100).ToString());//预热时间
            uiTextBox34.Text = ControlAttribute.TextBoxRead(uiTextBox34, (Convert.ToSingle(Global.rData.D2252) / 100).ToString());//上料传输时间
            uiTextBox35.Text = ControlAttribute.TextBoxRead(uiTextBox35, (Convert.ToSingle(Global.rData.D2220) / 100).ToString());//入料前等待时间
            uiTextBox36.Text = ControlAttribute.TextBoxRead(uiTextBox36, (Convert.ToSingle(Global.rData.D2302) / 100).ToString());//入料时间
            uiTextBox37.Text = ControlAttribute.TextBoxRead(uiTextBox37, (Convert.ToSingle(Global.rData.D2304) / 100).ToString());//入料后等待时间
            uiTextBox38.Text = ControlAttribute.TextBoxRead(uiTextBox38, (Convert.ToSingle(Global.rData.D2322) / 100).ToString());//减压后抽取戊烷时间
            uiTextBox39.Text = ControlAttribute.TextBoxRead(uiTextBox39, (Convert.ToSingle(Global.rData.D2324) / 100).ToString());//出料延时送风
            uiTextBox51.Text = ControlAttribute.TextBoxRead(uiTextBox51, Global.rData.D2016.ToString());//预热温度
            uiTextBox52.Text = ControlAttribute.TextBoxRead(uiTextBox52, (Convert.ToSingle(Global.rData.D2308) / 100).ToString());//吹扫加热时间
            uiTextBox54.Text = ControlAttribute.TextBoxRead(uiTextBox54, Global.rData.D2014.ToString());//吹扫加热比例阀开度
            uiTextBox53.Text = ControlAttribute.TextBoxRead(uiTextBox53, Global.rData.D2128.ToString());//吹扫加热压缩气开度
            uiTextBox55.Text = ControlAttribute.TextBoxRead(uiTextBox55, Global.rData.D2130.ToString());//主加热压缩气开度
            uiTextBox56.Text = ControlAttribute.TextBoxRead(uiTextBox56, Global.rData.D2038.ToString());//入料桶加压压力设定

            //***************常用参数**************
            uiTextBox103.Text = ControlAttribute.TextBoxRead(uiTextBox103, (Convert.ToSingle(Global.rData.D2268) / 100).ToString());//观察窗清扫打开时间
            uiTextBox102.Text = ControlAttribute.TextBoxRead(uiTextBox102, (Convert.ToSingle(Global.rData.D2270) / 100).ToString());//观察窗清扫关闭时间
            uiTextBox101.Text = ControlAttribute.TextBoxRead(uiTextBox101, (Convert.ToSingle(Global.rData.D2288) / 100).ToString());//入料清扫打开时间
            uiTextBox100.Text = ControlAttribute.TextBoxRead(uiTextBox100, (Convert.ToSingle(Global.rData.D2290) / 100).ToString());//入料清扫关闭时间
            uiTextBox99.Text = ControlAttribute.TextBoxRead(uiTextBox99, (Convert.ToSingle(Global.rData.D2292) / 100).ToString());//桶体清扫打开时间
            uiTextBox98.Text = ControlAttribute.TextBoxRead(uiTextBox98, (Convert.ToSingle(Global.rData.D2294) / 100).ToString());//桶体清扫关闭时间
            uiTextBox97.Text = ControlAttribute.TextBoxRead(uiTextBox97, (Convert.ToSingle(Global.rData.D2314) / 100).ToString());//上料真空打开时间
            uiTextBox96.Text = ControlAttribute.TextBoxRead(uiTextBox96, (Convert.ToSingle(Global.rData.D2312) / 100).ToString());//上料真空关闭时间
            uiTextBox95.Text = ControlAttribute.TextBoxRead(uiTextBox95, (Convert.ToSingle(Global.rData.D2296) / 100).ToString());//加热时传感器清扫开
            uiTextBox94.Text = ControlAttribute.TextBoxRead(uiTextBox94, (Convert.ToSingle(Global.rData.D2298) / 100).ToString());//加热时传感器清扫关
            uiTextBox93.Text = ControlAttribute.TextBoxRead(uiTextBox93, (Convert.ToSingle(Global.rData.D2280) / 100).ToString());//管道排水等待时间
            uiTextBox120.Text = ControlAttribute.TextBoxRead(uiTextBox120, (Convert.ToSingle(Global.rData.D2306) / 100).ToString());//切换半自动时间
            uiTextBox119.Text = ControlAttribute.TextBoxRead(uiTextBox119, (Convert.ToSingle(Global.rData.D2212) / 100).ToString());//底部清扫提前开时间
            uiTextBox183.Text = ControlAttribute.TextBoxRead(uiTextBox183, (Convert.ToSingle(Global.rData.D2330) / 100).ToString());//加热时入料清扫开
            uiTextBox184.Text = ControlAttribute.TextBoxRead(uiTextBox184, (Convert.ToSingle(Global.rData.D2332) / 100).ToString());//加热时入料清扫关

            uiTextBox92.Text = ControlAttribute.TextBoxRead(uiTextBox92, Global.rData.D2601.ToString());//自动清扫桶体次数
            uiTextBox91.Text = ControlAttribute.TextBoxRead(uiTextBox91, Global.rData.D2002.ToString());//称重慢放阈值
            uiTextBox104.Text = ControlAttribute.TextBoxRead(uiTextBox104, Global.rData.D2004.ToString());//称重完成阈值
            uiTextBox90.Text = ControlAttribute.TextBoxRead(uiTextBox90, Global.rData.D2114.ToString());//搅拌电机快速频率
            uiTextBox105.Text = ControlAttribute.TextBoxRead(uiTextBox105, Global.rData.D2116.ToString());//搅拌电机慢速频率
            uiTextBox106.Text = ControlAttribute.TextBoxRead(uiTextBox106, (Convert.ToSingle(Global.rData.D2282) / 100).ToString());//主轴快速搅拌时间
            uiTextBox124.Text = ControlAttribute.TextBoxRead(uiTextBox124, Global.rData.D2320.ToString());//震动传感器检测时间
            uiTextBox127.Text = ControlAttribute.TextBoxRead(uiTextBox127, Global.rData.D2126.ToString());//出料电流保护值
            uiTextBox128.Text = ControlAttribute.TextBoxRead(uiTextBox128, Global.rData.D2018.ToString());//最大电流保护值
            uiTextBox129.Text = ControlAttribute.TextBoxRead(uiTextBox129, (Convert.ToSingle(Global.rData.D2214) / 100).ToString());//料斗上料安全时间
            uiTextBox130.Text = ControlAttribute.TextBoxRead(uiTextBox130, (Convert.ToSingle(Global.rData.D2216) / 100).ToString());//电机停止时间

            uiTextBox137.Text = ControlAttribute.TextBoxRead(uiTextBox137, Global.rData.D2802.ToString());//控制小排气1压力上限
            uiTextBox136.Text = ControlAttribute.TextBoxRead(uiTextBox136, Global.rData.D2806.ToString());//控制小排气2压力上限
            uiTextBox135.Text = ControlAttribute.TextBoxRead(uiTextBox135, Global.rData.D2810.ToString());//控制大排气压力上限
            uiTextBox126.Text = ControlAttribute.TextBoxRead(uiTextBox126, Global.rData.D2800.ToString());//控制小排气1压力下限
            uiTextBox125.Text = ControlAttribute.TextBoxRead(uiTextBox125, Global.rData.D2804.ToString());//控制小排气2压力下限
            uiTextBox138.Text = ControlAttribute.TextBoxRead(uiTextBox138, Global.rData.D2808.ToString());//控制大排气压力下限

            //***************DWS参数**************
            uiTextBox70.Text = ControlAttribute.TextBoxRead(uiTextBox70, (Convert.ToSingle(Global.rData.D2254) / 100).ToString());//dws回吹时间
            uiTextBox69.Text = ControlAttribute.TextBoxRead(uiTextBox69, (Convert.ToSingle(Global.rData.D2256) / 100).ToString());//dws取样时间
            uiTextBox68.Text = ControlAttribute.TextBoxRead(uiTextBox68, (Convert.ToSingle(Global.rData.D2258) / 100).ToString());//dws采样检测反应时间
            uiTextBox67.Text = ControlAttribute.TextBoxRead(uiTextBox67, (Convert.ToSingle(Global.rData.D2260) / 100).ToString());//dws放样时间
            uiTextBox66.Text = ControlAttribute.TextBoxRead(uiTextBox66, (Convert.ToSingle(Global.rData.D2262) / 100).ToString());//dws快速放样提前终止时间
            uiTextBox65.Text = ControlAttribute.TextBoxRead(uiTextBox65, (Convert.ToSingle(Global.rData.D2264) / 100).ToString());//dws称重时间
            uiTextBox64.Text = ControlAttribute.TextBoxRead(uiTextBox64, (Convert.ToSingle(Global.rData.D2266) / 100).ToString());//dws回样时间
            uiTextBox185.Text = ControlAttribute.TextBoxRead(uiTextBox185, (Convert.ToSingle(Global.rData.D2328) / 100).ToString());//DWS开始时间
            uiTextBox59.Text = ControlAttribute.TextBoxRead(uiTextBox59, Global.rData.D2030.ToString());//控制小排气2压力下限
            uiTextBox58.Text = ControlAttribute.TextBoxRead(uiTextBox58, Global.rData.D2272.ToString());//主轴快速搅拌时间

            //***************报警限制**************
            uiTextBox74.Text = ControlAttribute.TextBoxRead(uiTextBox74, Global.rData.D2020.ToString());//主蒸汽压力上限报警
            uiTextBox73.Text = ControlAttribute.TextBoxRead(uiTextBox73, Global.rData.D2024.ToString());//压缩气压力上限报警
            uiTextBox72.Text = ControlAttribute.TextBoxRead(uiTextBox72, Global.rData.D2042.ToString());//发泡桶压力上限报警
            uiTextBox60.Text = ControlAttribute.TextBoxRead(uiTextBox60, Global.rData.D2022.ToString());//主蒸汽压力下限报警
            uiTextBox57.Text = ControlAttribute.TextBoxRead(uiTextBox57, Global.rData.D2026.ToString());//压缩气压力下限报警
            uiTextBox61.Text = ControlAttribute.TextBoxRead(uiTextBox61, Global.rData.D2040.ToString());//发泡桶压力下限报警

            //***************标定参数**************
            uiTextBox85.Text = ControlAttribute.TextBoxRead(uiTextBox85, Global.rData.D2066.ToString());//管道压力上限标定
            uiTextBox84.Text = ControlAttribute.TextBoxRead(uiTextBox84, Global.rData.D2070.ToString());//桶体压力上限标定
            uiTextBox83.Text = ControlAttribute.TextBoxRead(uiTextBox83, Global.rData.D2074.ToString());//桶体温度上限标定
            uiTextBox82.Text = ControlAttribute.TextBoxRead(uiTextBox82, Global.rData.D2078.ToString());//PHD温度上限标定
            uiTextBox81.Text = ControlAttribute.TextBoxRead(uiTextBox81, Global.rData.D2082.ToString());//主蒸汽压力上限标定
            uiTextBox80.Text = ControlAttribute.TextBoxRead(uiTextBox80, Global.rData.D2086.ToString());//压缩气压力上限标定
            uiTextBox79.Text = ControlAttribute.TextBoxRead(uiTextBox79, Global.rData.D2118.ToString());//主轴频率上限标定
            uiTextBox78.Text = ControlAttribute.TextBoxRead(uiTextBox78, Global.rData.D2122.ToString());//主轴电流上限标定
            uiTextBox77.Text = ControlAttribute.TextBoxRead(uiTextBox77, Global.rData.D2090.ToString());//称重仪表上限标定

            uiTextBox71.Text = ControlAttribute.TextBoxRead(uiTextBox71, Global.rData.D2068.ToString());//管道压力下限标定
            uiTextBox63.Text = ControlAttribute.TextBoxRead(uiTextBox63, Global.rData.D2072.ToString());//桶体压力下限标定
            uiTextBox86.Text = ControlAttribute.TextBoxRead(uiTextBox86, Global.rData.D2076.ToString());//桶体温度下限标定
            uiTextBox62.Text = ControlAttribute.TextBoxRead(uiTextBox62, Global.rData.D2080.ToString());//PHD温度下限标定
            uiTextBox87.Text = ControlAttribute.TextBoxRead(uiTextBox87, Global.rData.D2084.ToString());//主蒸汽压力下限标定
            uiTextBox88.Text = ControlAttribute.TextBoxRead(uiTextBox88, Global.rData.D2088.ToString());//压缩气压力下限标定
            uiTextBox75.Text = ControlAttribute.TextBoxRead(uiTextBox75, Global.rData.D2120.ToString());//主轴频率下限标定
            uiTextBox76.Text = ControlAttribute.TextBoxRead(uiTextBox76, Global.rData.D2124.ToString());//主轴电流上限标定
            uiTextBox89.Text = ControlAttribute.TextBoxRead(uiTextBox89, Global.rData.D2092.ToString());//称重仪表下限标定

            //***************PID参数**************
            //恒压
            uiTextBox146.Text = ControlAttribute.TextBoxRead(uiTextBox146, Global.rData.D2054.ToString());//比例增益(KP)
            uiTextBox145.Text = ControlAttribute.TextBoxRead(uiTextBox145, Global.rData.D2056.ToString());//积分时间(TI)
            uiTextBox144.Text = ControlAttribute.TextBoxRead(uiTextBox144, Global.rData.D2058.ToString());//微分增益(TD)
            uiTextBox143.Text = ControlAttribute.TextBoxRead(uiTextBox143, Global.rData.D2310.ToString());//采样时间(TS)
            uiTextBox110.Text = ControlAttribute.TextBoxRead(uiTextBox110, Global.rData.D2110.ToString());//输出上限设定值
            uiTextBox109.Text = ControlAttribute.TextBoxRead(uiTextBox109, Global.rData.D2108.ToString());//输出下限设定值
            uiTextBox147.Text = ControlAttribute.TextBoxRead(uiTextBox147, Global.rData.D2060.ToString());//微分时间(TD)
            uiTextBox108.Text = ControlAttribute.TextBoxRead(uiTextBox108, Global.rData.D2034.ToString());//参数代码
            //恒温
            uiTextBox149.Text = ControlAttribute.TextBoxRead(uiTextBox149, Global.rData.D2188.ToString());//比例增益(KP)
            uiTextBox148.Text = ControlAttribute.TextBoxRead(uiTextBox148, Global.rData.D2190.ToString());//积分时间(TI)
            uiTextBox142.Text = ControlAttribute.TextBoxRead(uiTextBox142, Global.rData.D2192.ToString());//微分增益(KD)
            uiTextBox117.Text = ControlAttribute.TextBoxRead(uiTextBox117, Global.rData.D2200.ToString());//采样时间(TS)
            uiTextBox116.Text = ControlAttribute.TextBoxRead(uiTextBox116, Global.rData.D2194.ToString());//输出上限设定值
            uiTextBox115.Text = ControlAttribute.TextBoxRead(uiTextBox115, Global.rData.D2198.ToString());//输出下限设定值
            uiTextBox150.Text = ControlAttribute.TextBoxRead(uiTextBox150, Global.rData.D2196.ToString());//微分时间(TD)
            uiTextBox107.Text = ControlAttribute.TextBoxRead(uiTextBox107, Global.rData.D2034.ToString());//参数代码

            uiTextBox157.Text = ControlAttribute.TextBoxRead(uiTextBox157, Global.rData.D2132.ToString());//STEM1_1
            uiTextBox156.Text = ControlAttribute.TextBoxRead(uiTextBox156, Global.rData.D2136.ToString());//STEM2_1
            uiTextBox155.Text = ControlAttribute.TextBoxRead(uiTextBox155, Global.rData.D2140.ToString());//STEM3_1
            uiTextBox154.Text = ControlAttribute.TextBoxRead(uiTextBox154, Global.rData.D2144.ToString());//STEM4_1
            uiTextBox163.Text = ControlAttribute.TextBoxRead(uiTextBox163, Global.rData.D2148.ToString());//STEM5_1
            uiTextBox164.Text = ControlAttribute.TextBoxRead(uiTextBox164, Global.rData.D2152.ToString());//STEM6_1
            uiTextBox165.Text = ControlAttribute.TextBoxRead(uiTextBox165, Global.rData.D2156.ToString());//STEM7_1
            uiTextBox166.Text = ControlAttribute.TextBoxRead(uiTextBox166, Global.rData.D2160.ToString());//STEM8_1
            uiTextBox167.Text = ControlAttribute.TextBoxRead(uiTextBox167, Global.rData.D2164.ToString());//STEM9_1
            uiTextBox153.Text = ControlAttribute.TextBoxRead(uiTextBox153, Global.rData.D2134.ToString());//STEM1_2
            uiTextBox152.Text = ControlAttribute.TextBoxRead(uiTextBox152, Global.rData.D2138.ToString());//STEM2_2
            uiTextBox151.Text = ControlAttribute.TextBoxRead(uiTextBox151, Global.rData.D2142.ToString());//STEM3_2
            uiTextBox158.Text = ControlAttribute.TextBoxRead(uiTextBox158, Global.rData.D2146.ToString());//STEM4_2
            uiTextBox168.Text = ControlAttribute.TextBoxRead(uiTextBox168, Global.rData.D2150.ToString());//STEM5_2
            uiTextBox169.Text = ControlAttribute.TextBoxRead(uiTextBox169, Global.rData.D2154.ToString());//STEM6_2
            uiTextBox170.Text = ControlAttribute.TextBoxRead(uiTextBox170, Global.rData.D2158.ToString());//STEM7_2
            uiTextBox171.Text = ControlAttribute.TextBoxRead(uiTextBox171, Global.rData.D2162.ToString());//STEM8_2
            uiTextBox172.Text = ControlAttribute.TextBoxRead(uiTextBox172, Global.rData.D2166.ToString());//STEM9_2
            uiTextBox159.Text = ControlAttribute.TextBoxRead(uiTextBox159, Global.rData.D2170.ToString());//STEM1_3
            uiTextBox160.Text = ControlAttribute.TextBoxRead(uiTextBox160, Global.rData.D2172.ToString());//STEM2_3
            uiTextBox161.Text = ControlAttribute.TextBoxRead(uiTextBox161, Global.rData.D2174.ToString());//STEM3_3
            uiTextBox162.Text = ControlAttribute.TextBoxRead(uiTextBox162, Global.rData.D2176.ToString());//STEM4_3
            uiTextBox173.Text = ControlAttribute.TextBoxRead(uiTextBox173, Global.rData.D2178.ToString());//STEM5_3
            uiTextBox174.Text = ControlAttribute.TextBoxRead(uiTextBox174, Global.rData.D2180.ToString());//STEM6_3
            uiTextBox175.Text = ControlAttribute.TextBoxRead(uiTextBox175, Global.rData.D2182.ToString());//STEM7_3
            uiTextBox176.Text = ControlAttribute.TextBoxRead(uiTextBox176, Global.rData.D2184.ToString());//STEM8_3
            uiTextBox177.Text = ControlAttribute.TextBoxRead(uiTextBox177, Global.rData.D2186.ToString());//STEM9_3

            //***************模块配置**************
            uiTextBox134.Text = ControlAttribute.TextBoxRead(uiTextBox134, Global.rData.D2224.ToString());//桶体温度通道
            uiTextBox133.Text = ControlAttribute.TextBoxRead(uiTextBox133, Global.rData.D2228.ToString());//管道温度通道
            uiTextBox132.Text = ControlAttribute.TextBoxRead(uiTextBox132, Global.rData.D2232.ToString());//蒸汽比例阀反馈通道
            uiTextBox131.Text = ControlAttribute.TextBoxRead(uiTextBox131, Global.rData.D2236.ToString());//压缩气比例阀反馈通道
            uiTextBox123.Text = ControlAttribute.TextBoxRead(uiTextBox123, Global.rData.D2238.ToString());//主蒸汽压力通道
            uiTextBox122.Text = ControlAttribute.TextBoxRead(uiTextBox122, Global.rData.D2244.ToString());//蒸汽比例阀输出通道
            uiTextBox121.Text = ControlAttribute.TextBoxRead(uiTextBox121, Global.rData.D2248.ToString());//排气比例阀输出通道
            uiTextBox118.Text = ControlAttribute.TextBoxRead(uiTextBox118, Global.rData.D2286.ToString());//料桶加压通道

            uiTextBox114.Text = ControlAttribute.TextBoxRead(uiTextBox114, Global.rData.D2226.ToString());//桶体压力通道
            uiTextBox113.Text = ControlAttribute.TextBoxRead(uiTextBox113, Global.rData.D2230.ToString());//管道压力通道
            uiTextBox139.Text = ControlAttribute.TextBoxRead(uiTextBox139, Global.rData.D2234.ToString());//排气比例阀反馈通道
            uiTextBox112.Text = ControlAttribute.TextBoxRead(uiTextBox112, Global.rData.D2242.ToString());//主轴电流检测通道
            uiTextBox140.Text = ControlAttribute.TextBoxRead(uiTextBox140, Global.rData.D2240.ToString());//压缩气压力通道
            uiTextBox141.Text = ControlAttribute.TextBoxRead(uiTextBox141, Global.rData.D2246.ToString());//压缩气比例阀输出通道
            uiTextBox111.Text = ControlAttribute.TextBoxRead(uiTextBox111, Global.rData.D2250.ToString());//主轴频率输出通道

            #endregion

            #region *******控件隐藏部分***********
            uiLabel48.Visible = Global.rData.D2620 == 1;
            uiTextBox34.Visible = Global.rData.D2620 == 1;
            uiLabel92.Visible = Global.rData.D2620 == 1;

            uiLabel107.Visible = Global.rData.D2621 == 1;
            uiTextBox38.Visible = Global.rData.D2621 == 1;
            uiLabel97.Visible = Global.rData.D2621 == 1;

            uiLabel41.Visible = Global.rData.D2624 == 1;
            uiTextBox51.Visible = Global.rData.D2624 == 1;
            uiLabel61.Visible = Global.rData.D2624 == 1;
            
            uiLabel55.Visible = Global.rData.D2244 != 0;
            uiTextBox54.Visible = Global.rData.D2244 != 0;
            uiLabel64.Visible = Global.rData.D2244 != 0;
            uiLabel93.Visible = Global.rData.D2246 != 0;
            uiTextBox53.Visible = Global.rData.D2246 != 0;
            uiLabel65.Visible = Global.rData.D2246 != 0;
            uiLabel50.Visible = Global.rData.D2246 != 0;
            uiTextBox55.Visible = Global.rData.D2246 != 0;
            uiLabel66.Visible = Global.rData.D2246 != 0;

            uiLabel45.Visible = Global.rData.D2286 != 0;
            uiTextBox56.Visible = Global.rData.D2286 != 0;
            uiLabel99.Visible = Global.rData.D2286 != 0;

            uiLabel186.Visible = Global.rData.D2618 == 0;
            uiTextBox97.Visible = Global.rData.D2618 == 0;
            uiLabel202.Visible = Global.rData.D2618 == 0;
            uiLabel181.Visible = Global.rData.D2618 == 0;
            uiTextBox96.Visible = Global.rData.D2618 == 0;
            uiLabel208.Visible = Global.rData.D2618 == 0;

            uiLabel183.Visible = Global.rData.D2622 == 1;
            uiTextBox91.Visible = Global.rData.D2622 == 1;
            uiLabel198.Visible = Global.rData.D2622 == 1;
            uiLabel192.Visible = Global.rData.D2622 == 1;
            uiTextBox104.Visible = Global.rData.D2622 == 1;
            uiLabel199.Visible = Global.rData.D2622 == 1;

            uiLabel182.Visible = Global.rData.D2250 != 0;
            uiTextBox90.Visible = Global.rData.D2250 != 0;
            uiLabel200.Visible = Global.rData.D2250 != 0;
            uiLabel189.Visible = Global.rData.D2250 != 0;
            uiTextBox105.Visible = Global.rData.D2250 != 0;
            uiLabel201.Visible = Global.rData.D2250 != 0;
            uiLabel187.Visible = Global.rData.D2250 != 0;
            uiTextBox106.Visible = Global.rData.D2250 != 0;
            uiLabel212.Visible = Global.rData.D2250 != 0;

            uiLabel180.Visible = Global.rData.D2242 != 0;
            uiTextBox127.Visible = Global.rData.D2242 != 0;
            uiLabel214.Visible = Global.rData.D2242 != 0;
            uiLabel178.Visible = Global.rData.D2242 != 0;
            uiTextBox128.Visible = Global.rData.D2242 != 0;
            uiLabel215.Visible = Global.rData.D2242 != 0;

            uiLabel273.Visible = Global.rData.D2626 == 1;
            uiTextBox137.Visible = Global.rData.D2626 == 1;
            uiLabel274.Visible = Global.rData.D2626 == 1;
            uiLabel262.Visible = Global.rData.D2626 == 1;
            uiTextBox126.Visible = Global.rData.D2626 == 1;
            uiLabel275.Visible = Global.rData.D2626 == 1;
            uiLabel272.Visible = Global.rData.D2626 == 1;
            uiTextBox136.Visible = Global.rData.D2626 == 1;
            uiLabel281.Visible = Global.rData.D2626 == 1;
            uiLabel261.Visible = Global.rData.D2626 == 1;
            uiTextBox125.Visible = Global.rData.D2626 == 1;
            uiLabel276.Visible = Global.rData.D2626 == 1;
            uiLabel271.Visible = Global.rData.D2626 == 1;
            uiTextBox135.Visible = Global.rData.D2626 == 1;
            uiLabel282.Visible = Global.rData.D2626 == 1;
            uiLabel270.Visible = Global.rData.D2626 == 1;
            uiTextBox138.Visible = Global.rData.D2626 == 1;
            uiLabel277.Visible = Global.rData.D2626 == 1;

            uiTableLayoutPanel5.Visible = Global.rData.D2619 == 1;//DWS参数隐藏

            uiLabel116.Visible = Global.rData.D2238 != 0;
            uiTextBox74.Visible = Global.rData.D2238 != 0;
            uiLabel119.Visible = Global.rData.D2238 != 0;
            uiLabel103.Visible = Global.rData.D2238 != 0;
            uiTextBox60.Visible = Global.rData.D2238 != 0;
            uiLabel121.Visible = Global.rData.D2238 != 0;

            uiLabel115.Visible = Global.rData.D2240 != 0;
            uiTextBox73.Visible = Global.rData.D2240 != 0;
            uiLabel133.Visible = Global.rData.D2240 != 0;
            uiLabel100.Visible = Global.rData.D2240 != 0;
            uiTextBox57.Visible = Global.rData.D2240 != 0;
            uiLabel123.Visible = Global.rData.D2240 != 0;

            uiLabel114.Visible = Global.rData.D2226 != 0 || Global.rData.D2230 != 0;
            uiTextBox72.Visible = Global.rData.D2226 != 0 || Global.rData.D2230 != 0;
            uiLabel134.Visible = Global.rData.D2226 != 0 || Global.rData.D2230 != 0;
            uiLabel144.Visible = Global.rData.D2226 != 0 || Global.rData.D2230 != 0;
            uiTextBox61.Visible = Global.rData.D2226 != 0 || Global.rData.D2230 != 0;
            uiLabel145.Visible = Global.rData.D2226 != 0 || Global.rData.D2230 != 0;

            uiLabel159.Visible = Global.rData.D2230 != 0;
            uiTextBox85.Visible = Global.rData.D2230 != 0;
            uiLabel160.Visible = Global.rData.D2230 != 0;
            uiLabel148.Visible = Global.rData.D2230 != 0;
            uiTextBox71.Visible = Global.rData.D2230 != 0;
            uiLabel161.Visible = Global.rData.D2230 != 0;

            uiLabel151.Visible = Global.rData.D2226 != 0;
            uiTextBox84.Visible = Global.rData.D2226 != 0;
            uiLabel167.Visible = Global.rData.D2226 != 0;
            uiLabel147.Visible = Global.rData.D2226 != 0;
            uiTextBox63.Visible = Global.rData.D2226 != 0;
            uiLabel162.Visible = Global.rData.D2226 != 0;

            uiLabel157.Visible = Global.rData.D2224 != 0;
            uiTextBox83.Visible = Global.rData.D2224 != 0;
            uiLabel168.Visible = Global.rData.D2224 != 0;
            uiLabel156.Visible = Global.rData.D2224 != 0;
            uiTextBox86.Visible = Global.rData.D2224 != 0;
            uiLabel163.Visible = Global.rData.D2224 != 0;

            uiLabel155.Visible = Global.rData.D2228 != 0;
            uiTextBox82.Visible = Global.rData.D2228 != 0;
            uiLabel169.Visible = Global.rData.D2228 != 0;
            uiLabel146.Visible = Global.rData.D2228 != 0;
            uiTextBox62.Visible = Global.rData.D2228 != 0;
            uiLabel164.Visible = Global.rData.D2228 != 0;

            uiLabel154.Visible = Global.rData.D2238 != 0;
            uiTextBox81.Visible = Global.rData.D2238 != 0;
            uiLabel170.Visible = Global.rData.D2238 != 0;
            uiLabel153.Visible = Global.rData.D2238 != 0;
            uiTextBox87.Visible = Global.rData.D2238 != 0;
            uiLabel165.Visible = Global.rData.D2238 != 0;

            uiLabel152.Visible = Global.rData.D2240 != 0;
            uiTextBox80.Visible = Global.rData.D2240 != 0;
            uiLabel171.Visible = Global.rData.D2240 != 0;
            uiLabel151.Visible = Global.rData.D2240 != 0;
            uiTextBox88.Visible = Global.rData.D2240 != 0;
            uiLabel176.Visible = Global.rData.D2240 != 0;

            uiLabel150.Visible = Global.rData.D2250 != 0;
            uiTextBox79.Visible = Global.rData.D2250 != 0;
            uiLabel166.Visible = Global.rData.D2250 != 0;
            uiLabel149.Visible = Global.rData.D2250 != 0;
            uiTextBox75.Visible = Global.rData.D2250 != 0;
            uiLabel106.Visible = Global.rData.D2250 != 0;

            uiLabel143.Visible = Global.rData.D2242 != 0;
            uiTextBox78.Visible = Global.rData.D2242 != 0;
            uiLabel172.Visible = Global.rData.D2242 != 0;
            uiLabel142.Visible = Global.rData.D2242 != 0;
            uiTextBox76.Visible = Global.rData.D2242 != 0;
            uiLabel109.Visible = Global.rData.D2242 != 0;

            uiLabel135.Visible = Global.rData.D2630 == 1;
            uiTextBox77.Visible = Global.rData.D2630 == 1;
            uiLabel173.Visible = Global.rData.D2630 == 1;
            uiLabel126.Visible = Global.rData.D2630 == 1;
            uiTextBox89.Visible = Global.rData.D2630 == 1;
            uiLabel112.Visible = Global.rData.D2630 == 1;

            uiTableLayoutPanel13.Visible = Global.rData.D2244 != 0;
            uiTableLayoutPanel14.Visible = (Global.rData.D2244 != 0 && Global.rData.D2246 != 0);

            #endregion

            //********************
            //*****IO管理*********
            //********************
            #region ******************输入*******************
            uiLight33.State = (Global.rData.gX[0] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight34.State = (Global.rData.gX[1] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight35.State = (Global.rData.gX[2] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight40.State = (Global.rData.gX[3] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight41.State = (Global.rData.gX[4] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight42.State = (Global.rData.gX[5] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight43.State = (Global.rData.gX[6] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight44.State = (Global.rData.gX[7] == true) ? UILightState.On : uiLight1.State = UILightState.Off;

            uiLight45.State = (Global.rData.gX[8] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight46.State = (Global.rData.gX[9] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight47.State = (Global.rData.gX[10] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight48.State = (Global.rData.gX[11] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight49.State = (Global.rData.gX[12] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight50.State = (Global.rData.gX[13] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight51.State = (Global.rData.gX[14] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight36.State = (Global.rData.gX[15] == true) ? UILightState.On : uiLight1.State = UILightState.Off;

            uiLight38.State = (Global.rData.gX[16] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight37.State = (Global.rData.gX[17] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight39.State = (Global.rData.gX[18] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight52.State = (Global.rData.gX[19] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight53.State = (Global.rData.gX[20] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight54.State = (Global.rData.gX[21] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight55.State = (Global.rData.gX[22] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight56.State = (Global.rData.gX[23] == true) ? UILightState.On : uiLight1.State = UILightState.Off;

            uiLight57.State = (Global.rData.gX[24] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight58.State = (Global.rData.gX[25] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight59.State = (Global.rData.gX[26] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight60.State = (Global.rData.gX[27] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight61.State = (Global.rData.gX[28] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight62.State = (Global.rData.gX[29] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight63.State = (Global.rData.gX[30] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight64.State = (Global.rData.gX[31] == true) ? UILightState.On : uiLight1.State = UILightState.Off;

            uiLight65.State = (Global.rData.gX[32] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight66.State = (Global.rData.gX[33] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight67.State = (Global.rData.gX[34] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight68.State = (Global.rData.gX[35] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight69.State = (Global.rData.gX[36] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight70.State = (Global.rData.gX[37] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight71.State = (Global.rData.gX[38] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            uiLight72.State = (Global.rData.gX[39] == true) ? UILightState.On : uiLight1.State = UILightState.Off;
            #endregion

            #region ******************输出*******************
            if (Global.rData.gM0[0] == true)//上放料阀
            {
                ControlAttribute.Button_Control(uiButton28, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton28, Color.DarkGray);
            }
            if (Global.rData.gM0[2] == true)//称重快放
            {
                ControlAttribute.Button_Control(uiButton29, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton29, Color.DarkGray);
            }
            if (Global.rData.gM0[3] == true)//称重慢放
            {
                ControlAttribute.Button_Control(uiButton31, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton31, Color.DarkGray);
            }
            if (Global.rData.gM0[4] == true)//入料清扫
            {
                ControlAttribute.Button_Control(uiButton33, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton33, Color.DarkGray);
            }
            if (Global.rData.gM0[1] == true)//下放料阀
            {
                ControlAttribute.Button_Control(uiButton35, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton35, Color.DarkGray);
            }
            if (Global.rData.gM0[22] == true)//进风阀
            {
                ControlAttribute.Button_Control(uiButton34, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton34, Color.DarkGray);
            }
            if (Global.rData.gM0[5] == true)//传感器清扫
            {
                ControlAttribute.Button_Control(uiButton30, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton30, Color.DarkGray);
            }
            if (Global.rData.gM0[7] == true)//运行灯
            {
                ControlAttribute.Button_Control(uiButton32, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton32, Color.DarkGray);
            }
            if (Global.rData.gM0[10] == true)//大排气
            {
                ControlAttribute.Button_Control(uiButton37, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton37, Color.DarkGray);
            }
            if (Global.rData.gM0[11] == true)//排气阀1
            {
                ControlAttribute.Button_Control(uiButton38, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton38, Color.DarkGray);
            }
            if (Global.rData.gM0[12] == true)//排气阀2
            {
                ControlAttribute.Button_Control(uiButton36, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton36, Color.DarkGray);
            }
            if (Global.rData.gM0[13] == true)//吸风阀
            {
                ControlAttribute.Button_Control(uiButton39, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton39, Color.DarkGray);
            }
            if (Global.rData.gM0[14] == true)//桶体清扫
            {
                ControlAttribute.Button_Control(uiButton40, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton40, Color.DarkGray);
            }
            if (Global.rData.gM0[24] == true)//管道排水
            {
                ControlAttribute.Button_Control(uiButton41, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton41, Color.DarkGray);
            }
            if (Global.rData.gM0[21] == true)//桶体排水
            {
                ControlAttribute.Button_Control(uiButton42, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton42, Color.DarkGray);
            }
            if (Global.rData.gM0[43] == true)//蒸汽副阀
            {
                ControlAttribute.Button_Control(uiButton43, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton43, Color.DarkGray);
            }
            if (Global.rData.gM0[16] == true)//温度调节
            {
                ControlAttribute.Button_Control(uiButton44, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton44, Color.DarkGray);
            }
            if (Global.rData.gM0[15] == true)//出料口清扫
            {
                ControlAttribute.Button_Control(uiButton45, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton45, Color.DarkGray);
            }
            if (Global.rData.gM0[26] == true)//压缩气1
            {
                ControlAttribute.Button_Control(uiButton46, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton46, Color.DarkGray);
            }
            if (Global.rData.gM0[17] == true)//压缩气2
            {
                ControlAttribute.Button_Control(uiButton47, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton47, Color.DarkGray);
            }
            if (Global.rData.gM0[23] == true)//*出料阀门
            {
                ControlAttribute.Button_Control(uiButton48, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton48, Color.DarkGray);
            }
            if (Global.rData.gM0[42] == true)//*底部清扫
            {
                ControlAttribute.Button_Control(uiButton49, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton49, Color.DarkGray);
            }
            if (Global.rData.gM0[36] == true)//报警灯
            {
                ControlAttribute.Button_Control(uiButton50, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton50, Color.DarkGray);
            }
            if (Global.rData.gM0[33] == true)//上料风机
            {
                ControlAttribute.Button_Control(uiButton51, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton51, Color.DarkGray);
            }
            if (Global.rData.gM0[30] == true)//搅拌电机
            {
                ControlAttribute.Button_Control(uiButton52, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton52, Color.DarkGray);
            }
            if (Global.rData.gM0[27] == true)//上料电机
            {
                ControlAttribute.Button_Control(uiButton53, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton53, Color.DarkGray);
            }
            if (Global.rData.gM0[37] == true)//震动电机/流化床挡板
            {
                ControlAttribute.Button_Control(uiButton54, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton54, Color.DarkGray);
            }
            if (Global.rData.gM0[34] == true)//送料风机
            {
                ControlAttribute.Button_Control(uiButton55, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton55, Color.DarkGray);
            }
            if (Global.rData.gM0[35] == true)//破碎电机
            {
                ControlAttribute.Button_Control(uiButton56, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton56, Color.DarkGray);
            }
            if (Global.rData.gM0[20] == true)//干燥电机
            {
                ControlAttribute.Button_Control(uiButton57, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton57, Color.DarkGray);
            }
            if (Global.rData.gM0[40] == true)//翻板电机
            {
                ControlAttribute.Button_Control(uiButton58, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton58, Color.DarkGray);
            }
            if (Global.rData.gM0[32] == true)//送风风机
            {
                ControlAttribute.Button_Control(uiButton60, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton60, Color.DarkGray);
            }
            if (Global.rData.gM0[44] == true)//粉碎电机
            {
                ControlAttribute.Button_Control(uiButton61, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton61, Color.DarkGray);
            }
            if (Global.rData.gM0[41] == true)//料斗上料
            {
                ControlAttribute.Button_Control(uiButton62, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton62, Color.DarkGray);
            }
            if (Global.rData.gM0[31] == true)//料斗吸风
            {
                ControlAttribute.Button_Control(uiButton63, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton63, Color.DarkGray);
            }
            if (Global.rData.gM0[6] == true)//排风阀
            {
                ControlAttribute.Button_Control(uiButton64, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton64, Color.DarkGray);
            }
            if (Global.rData.gM0[25] == true)//料斗加压
            {
                ControlAttribute.Button_Control(uiButton59, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton59, Color.DarkGray);
            }
            if (Global.rData.gM0[45] == true)//吸料阀
            {
                ControlAttribute.Button_Control(uiButton65, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton65, Color.DarkGray);
            }
            if (Global.rData.gM0[46] == true)//上料传输
            {
                ControlAttribute.Button_Control(uiButton66, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton66, Color.DarkGray);
            }
            if (Global.rData.gM0[47] == true)//料斗抽风阀
            {
                ControlAttribute.Button_Control(uiButton67, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton67, Color.DarkGray);
            }
            if (Global.rData.gM0[50] == true)//DWS刮平气缸
            {
                ControlAttribute.Button_Control(uiButton12, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton12, Color.DarkGray);
            }
            if (Global.rData.gM0[51] == true)//DWS升降气缸
            {
                ControlAttribute.Button_Control(uiButton13, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton13, Color.DarkGray);
            }
            if (Global.rData.gM0[52] == true)//DWS料斗关
            {
                ControlAttribute.Button_Control(uiButton14, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton14, Color.DarkGray);
            }
            if (Global.rData.gM0[53] == true)//DWS料斗开
            {
                ControlAttribute.Button_Control(uiButton15, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton15, Color.DarkGray);
            }
            if (Global.rData.gM0[54] == true)//DWS吸料开关
            {
                ControlAttribute.Button_Control(uiButton16, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton16, Color.DarkGray);
            }
            if (Global.rData.gM0[55] == true)//DWS放样清扫
            {
                ControlAttribute.Button_Control(uiButton17, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton17, Color.DarkGray);
            }
            if (Global.rData.gM0[56] == true)//DWS料斗清扫
            {
                ControlAttribute.Button_Control(uiButton18, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton18, Color.DarkGray);
            }
            if (Global.rData.gM0[57] == true)//DWS真空吸料
            {
                ControlAttribute.Button_Control(uiButton19, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton19, Color.DarkGray);
            }
            if (Global.rData.gM0[60] == true)//DWS吸料回吹
            {
                ControlAttribute.Button_Control(uiButton20, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton20, Color.DarkGray);
            }
            if (Global.rData.gM0[61] == true)//DWS回样阀
            {
                ControlAttribute.Button_Control(uiButton21, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton21, Color.DarkGray);
            }
            if (Global.rData.gM0[62] == true)//DWS取用电机
            {
                ControlAttribute.Button_Control(uiButton22, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton22, Color.DarkGray);
            }
            if (Global.rData.gM0[63] == true)//真空总阀
            {
                ControlAttribute.Button_Control(uiButton23, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton23, Color.DarkGray);
            }
            if (Global.rData.gM0[64] == true)//真空排气
            {
                ControlAttribute.Button_Control(uiButton24, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton24, Color.DarkGray);
            }
            if (Global.rData.gM0[65] == true)//二次入料阀
            {
                ControlAttribute.Button_Control(uiButton25, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton25, Color.DarkGray);
            }
            if (Global.rData.gM0[66] == true)//二次翻板电机
            {
                ControlAttribute.Button_Control(uiButton26, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton26, Color.DarkGray);
            }
            if (Global.rData.gM0[67] == true)//二次上料电机
            {
                ControlAttribute.Button_Control(uiButton27, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton27, Color.DarkGray);
            }
            if (Global.rData.gM100[0] == true)//蒸汽比例阀
            {
                ControlAttribute.Button_Control(uiButton8, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton8, Color.DarkGray);
            }
            if (Global.rData.gM100[2] == true)//压缩气比例阀
            {
                ControlAttribute.Button_Control(uiButton9, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton9, Color.DarkGray);
            }
            if (Global.rData.gM100[1] == true)//排气比例阀
            {
                ControlAttribute.Button_Control(uiButton10, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton10, Color.DarkGray);
            }
            if (Global.rData.gM100[3] == true)//入料桶比例阀
            {
                ControlAttribute.Button_Control(uiButton11, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton11, Color.DarkGray);
            }
            uiTextBox41.Text = ControlAttribute.TextBoxRead(uiTextBox41, Global.rData.D1028.ToString());//蒸汽比例阀实际开度
            uiTextBox43.Text = ControlAttribute.TextBoxRead(uiTextBox43, Global.rData.D1040.ToString());//空气比例阀实际开度
            uiTextBox45.Text = ControlAttribute.TextBoxRead(uiTextBox45, Global.rData.D1020.ToString());//排气比例阀实际开度
            uiTextBox40.Text = ControlAttribute.TextBoxRead(uiTextBox40, Global.rData.D2062.ToString());//蒸汽比例阀
            uiTextBox42.Text = ControlAttribute.TextBoxRead(uiTextBox42, Global.rData.D2112.ToString());//空气比例阀
            uiTextBox44.Text = ControlAttribute.TextBoxRead(uiTextBox44, Global.rData.D2050.ToString());//排气比例阀
            uiTextBox46.Text = ControlAttribute.TextBoxRead(uiTextBox46, Global.rData.D2036.ToString());//入料桶压力
            uiTextBox47.Text = uiTextBox46.Text;//入料桶压力
            #endregion

            #region *******控件隐藏部分***********
            uiButton8.Visible = Global.rData.D2244 != 0;
            uiTextBox41.Visible = Global.rData.D2244 != 0;
            uiTextBox40.Visible = Global.rData.D2244 != 0;
            uiLabel428.Visible = Global.rData.D2244 != 0;

            uiButton9.Visible = Global.rData.D2246 != 0;
            uiTextBox43.Visible = Global.rData.D2246 != 0;
            uiTextBox42.Visible = Global.rData.D2246 != 0;
            uiLabel430.Visible = Global.rData.D2246 != 0;

            uiButton10.Visible = Global.rData.D2248 != 0;
            uiTextBox45.Visible = Global.rData.D2248 != 0;
            uiTextBox44.Visible = Global.rData.D2248 != 0;
            uiLabel431.Visible = Global.rData.D2248 != 0;

            uiButton11.Visible = Global.rData.D2286 != 0;
            uiTextBox46.Visible = Global.rData.D2286 != 0;
            uiTextBox47.Visible = Global.rData.D2286 != 0;
            uiLabel429.Visible = Global.rData.D2286 != 0;

            uiLabel403.Visible = Global.rData.D2629 == 1;
            uiButton23.Visible = Global.rData.D2629 == 1;
            uiLabel404.Visible = Global.rData.D2629 == 1;
            uiButton24.Visible = Global.rData.D2629 == 1;

            uiLabel405.Visible = Global.rData.D2623 == 1;
            uiButton25.Visible = Global.rData.D2623 == 1;
            uiLabel406.Visible = Global.rData.D2623 == 1;
            uiButton26.Visible = Global.rData.D2623 == 1;
            uiLabel407.Visible = Global.rData.D2623 == 1;
            uiButton27.Visible = Global.rData.D2623 == 1;

            uiLabel392.Visible = Global.rData.D2619 == 1;
            uiButton12.Visible = Global.rData.D2619 == 1;
            uiLabel393.Visible = Global.rData.D2619 == 1;
            uiButton13.Visible = Global.rData.D2619 == 1;
            uiLabel394.Visible = Global.rData.D2619 == 1;
            uiButton14.Visible = Global.rData.D2619 == 1;
            uiLabel395.Visible = Global.rData.D2619 == 1;
            uiButton15.Visible = Global.rData.D2619 == 1;
            uiLabel396.Visible = Global.rData.D2619 == 1;
            uiButton16.Visible = Global.rData.D2619 == 1;
            uiLabel397.Visible = Global.rData.D2619 == 1;
            uiButton17.Visible = Global.rData.D2619 == 1;
            uiLabel398.Visible = Global.rData.D2619 == 1;
            uiButton18.Visible = Global.rData.D2619 == 1;
            uiLabel399.Visible = Global.rData.D2619 == 1;
            uiButton19.Visible = Global.rData.D2619 == 1;
            uiLabel400.Visible = Global.rData.D2619 == 1;
            uiButton20.Visible = Global.rData.D2619 == 1;
            uiLabel401.Visible = Global.rData.D2619 == 1;
            uiButton21.Visible = Global.rData.D2619 == 1;
            uiLabel402.Visible = Global.rData.D2619 == 1;
            uiButton22.Visible = Global.rData.D2619 == 1;

            uiLabel374.Visible = Global.rData.D2620 == 1;
            uiButton51.Visible = Global.rData.D2620 == 1;
            uiLabel389.Visible = Global.rData.D2620 == 1;
            uiButton66.Visible = Global.rData.D2620 == 1;

            uiLabel80.Visible = Global.rData.D2621 == 1;
            uiButton39.Visible = Global.rData.D2621 == 1;

            uiLabel384.Visible = Global.rData.D2618 == 0;
            uiButton62.Visible = Global.rData.D2618 == 0;
            uiLabel390.Visible = Global.rData.D2618 == 0;
            uiButton67.Visible = Global.rData.D2618 == 0;

            uiLabel385.Visible = Global.rData.D2284 == 2;
            uiButton63.Visible = Global.rData.D2284 == 2;
            uiLabel387.Visible = Global.rData.D2284 == 2;
            uiButton64.Visible = Global.rData.D2284 == 2;
            uiLabel386.Visible = Global.rData.D2284 == 2;
            uiButton59.Visible = Global.rData.D2284 == 2;
            uiLabel388.Visible = Global.rData.D2284 == 2;
            uiButton65.Visible = Global.rData.D2284 == 2;
            #endregion
            //********************
            //*****电机管理*******
            //********************
            #region *************电机管理******************
            if (Global.rData.gM0[30] == true)//搅拌电机
            {
                ControlAttribute.Button_Control(uiButton1, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton1, Color.DarkGray);
            }
            if (Global.rData.gM0[37] == true)//震动电机
            {
                ControlAttribute.Button_Control(uiButton2, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton2, Color.DarkGray);
            }
            if (Global.rData.gM0[34] == true)//送料风机
            {
                ControlAttribute.Button_Control(uiButton3, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton3, Color.DarkGray);
            }
            if (Global.rData.gM0[35] == true)//破碎电机
            {
                ControlAttribute.Button_Control(uiButton4, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton4, Color.DarkGray);
            }
            if (Global.rData.gM0[20] == true)//干燥电机
            {
                ControlAttribute.Button_Control(uiButton5, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton5, Color.DarkGray);
            }
            if (Global.rData.gM0[40] == true)//翻板电机
            {
                ControlAttribute.Button_Control(uiButton6, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton6, Color.DarkGray);
            }
            if (Global.rData.gM0[44] == true)//粉碎电机
            {
                ControlAttribute.Button_Control(uiButton7, Color.LimeGreen);
            }
            else
            {
                ControlAttribute.Button_Control(uiButton7, Color.DarkGray);
            }
            #endregion
            //********************
            //*****报警管理*******
            //********************
            #region **************报警管理*****************
            uiSymbolButton1.FillDisableColor = (Global.rData.gS0[0] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton1.ForeDisableColor = Color.WhiteSmoke;
            rTrig0.CLK = Global.rData.gS0[0];
            if (rTrig0.Q)//称重超时报警
            {
                uiScrollingText1.Text = uiSymbolButton1.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }
                
            uiSymbolButton2.FillDisableColor = (Global.rData.gS0[1] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton2.ForeDisableColor = Color.WhiteSmoke;
            rTrig1.CLK = Global.rData.gS0[1];
            if (rTrig1.Q)//入料超时报警
            {
                uiScrollingText1.Text = uiSymbolButton2.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            } 

            uiSymbolButton3.FillDisableColor = (Global.rData.gS0[2] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton3.ForeDisableColor = Color.WhiteSmoke;
            rTrig2.CLK = Global.rData.gS0[2];
            if (rTrig2.Q)//料位传感器报警
            {
                uiScrollingText1.Text = uiSymbolButton3.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton4.FillDisableColor = (Global.rData.gS0[3] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton4.ForeDisableColor = Color.WhiteSmoke;
            rTrig3.CLK = Global.rData.gS0[3];
            if (rTrig3.Q)//搅拌电机过载
            {
                uiScrollingText1.Text = uiSymbolButton4.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }  

            uiSymbolButton5.FillDisableColor = (Global.rData.gS0[4] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton5.ForeDisableColor = Color.WhiteSmoke;
            rTrig4.CLK = Global.rData.gS0[4];
            if (rTrig4.Q)//上料电机过载
            {
                uiScrollingText1.Text = uiSymbolButton5.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            } 

            uiSymbolButton6.FillDisableColor = (Global.rData.gS0[5] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton6.ForeDisableColor = Color.WhiteSmoke;
            rTrig5.CLK = Global.rData.gS0[5];
            if (rTrig5.Q)//破碎电机过载
            {
                uiScrollingText1.Text = uiSymbolButton6.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }   

            uiSymbolButton7.FillDisableColor = (Global.rData.gS0[6] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton7.ForeDisableColor = Color.WhiteSmoke;
            rTrig6.CLK = Global.rData.gS0[6];
            if (rTrig6.Q)//翻板电机过载
            {
                uiScrollingText1.Text = uiSymbolButton7.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton8.FillDisableColor = (Global.rData.gS0[7] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton8.ForeDisableColor = Color.WhiteSmoke;
            rTrig7.CLK = Global.rData.gS0[7];
            if (rTrig7.Q)//送料电机过载
            {
                uiScrollingText1.Text = uiSymbolButton8.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton9.FillDisableColor = (Global.rData.gS0[8] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton9.ForeDisableColor = Color.WhiteSmoke;
            rTrig8.CLK = Global.rData.gS0[8];
            if (rTrig8.Q)//震动电机过载
            {
                uiScrollingText1.Text = uiSymbolButton9.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton10.FillDisableColor = (Global.rData.gS0[9] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton10.ForeDisableColor = Color.WhiteSmoke;
            rTrig9.CLK = Global.rData.gS0[9];
            if (rTrig9.Q)//送风电机过载
            {
                uiScrollingText1.Text = uiSymbolButton10.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton11.FillDisableColor = (Global.rData.gS0[10] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton11.ForeDisableColor = Color.WhiteSmoke;
            rTrig10.CLK = Global.rData.gS0[10];
            if (rTrig10.Q)//桶体压力达到上限
            {
                uiScrollingText1.Text = uiSymbolButton11.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }
                
            uiSymbolButton28.FillDisableColor = (Global.rData.gS0[11] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton28.ForeDisableColor = Color.WhiteSmoke;
            rTrig11.CLK = Global.rData.gS0[11];
            if (rTrig11.Q)//压缩气气压低
            {
                uiScrollingText1.Text = uiSymbolButton28.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }
                
            uiSymbolButton12.FillDisableColor = (Global.rData.gS0[12] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton12.ForeDisableColor = Color.WhiteSmoke;
            rTrig12.CLK = Global.rData.gS0[12];
            if (rTrig12.Q)//主蒸汽气压低
            {
                uiScrollingText1.Text = uiSymbolButton12.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton14.FillDisableColor = (Global.rData.gS0[14] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton14.ForeDisableColor = Color.WhiteSmoke;
            rTrig14.CLK = Global.rData.gS0[14];
            if (rTrig14.Q)//生产批次结束
            {
                uiScrollingText1.Text = uiSymbolButton14.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton13.FillDisableColor = (Global.rData.gS0[15] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton13.ForeDisableColor = Color.WhiteSmoke;
            rTrig15.CLK = Global.rData.gS0[15];
            if (rTrig15.Q)//加热到最大时间
            {
                uiScrollingText1.Text = uiSymbolButton13.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton15.FillDisableColor = (Global.rData.gS0[16] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton15.ForeDisableColor = Color.WhiteSmoke;
            rTrig16.CLK = Global.rData.gS0[16];
            if (rTrig16.Q)//加热时电流过大
            {
                uiScrollingText1.Text = uiSymbolButton15.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton16.FillDisableColor = (Global.rData.gS0[17] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton16.ForeDisableColor = Color.WhiteSmoke;
            rTrig17.CLK = Global.rData.gS0[17];
            if (rTrig17.Q)//主蒸汽压力高
            {
                uiScrollingText1.Text = uiSymbolButton16.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton17.FillDisableColor = (Global.rData.gS0[18] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton17.ForeDisableColor = Color.WhiteSmoke;
            rTrig18.CLK = Global.rData.gS0[18];
            if (rTrig18.Q)//压缩气压力高
            {
                uiScrollingText1.Text = uiSymbolButton17.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton18.FillDisableColor = (Global.rData.gS0[19] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton18.ForeDisableColor = Color.WhiteSmoke;
            rTrig19.CLK = Global.rData.gS0[19];
            if (rTrig19.Q)
            {
                uiScrollingText1.Text = uiSymbolButton18.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton19.FillDisableColor = (Global.rData.gS0[20] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton19.ForeDisableColor = Color.WhiteSmoke;
            rTrig20.CLK = Global.rData.gS0[20];
            if (rTrig20.Q)
            {
                uiScrollingText1.Text = uiSymbolButton19.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton20.FillDisableColor = (Global.rData.gS0[21] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton20.ForeDisableColor = Color.WhiteSmoke;
            rTrig21.CLK = Global.rData.gS0[21];
            if (rTrig21.Q)
            {
                uiScrollingText1.Text = uiSymbolButton20.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton21.FillDisableColor = (Global.rData.gS0[22] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton21.ForeDisableColor = Color.WhiteSmoke;
            rTrig22.CLK = Global.rData.gS0[22];
            if (rTrig22.Q)
            {
                uiScrollingText1.Text = uiSymbolButton21.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton22.FillDisableColor = (Global.rData.gS0[23] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton22.ForeDisableColor = Color.WhiteSmoke;
            rTrig23.CLK = Global.rData.gS0[23];
            if (rTrig23.Q)
            {
                uiScrollingText1.Text = uiSymbolButton22.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton23.FillDisableColor = (Global.rData.gS0[24] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton23.ForeDisableColor = Color.WhiteSmoke;
            rTrig24.CLK = Global.rData.gS0[24];
            if (rTrig24.Q)
            {
                uiScrollingText1.Text = uiSymbolButton23.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton24.FillDisableColor = (Global.rData.gS0[25] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton24.ForeDisableColor = Color.WhiteSmoke;
            rTrig25.CLK = Global.rData.gS0[25];
            if (rTrig25.Q)
            {
                uiScrollingText1.Text = uiSymbolButton24.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton25.FillDisableColor = (Global.rData.gS0[26] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton25.ForeDisableColor = Color.WhiteSmoke;
            rTrig26.CLK = Global.rData.gS0[26];
            if (rTrig26.Q)
            {
                uiScrollingText1.Text = uiSymbolButton25.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton26.FillDisableColor = (Global.rData.gS0[27] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton26.ForeDisableColor = Color.WhiteSmoke;
            rTrig27.CLK = Global.rData.gS0[27];
            if (rTrig27.Q)
            {
                uiScrollingText1.Text = uiSymbolButton26.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton34.FillDisableColor = (Global.rData.gS0[28] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton34.ForeDisableColor = Color.WhiteSmoke;
            rTrig28.CLK = Global.rData.gS0[28];
            if (rTrig4.Q)
            {
                uiScrollingText1.Text = uiSymbolButton34.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton37.FillDisableColor = (Global.rData.gS0[29] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton37.ForeDisableColor = Color.WhiteSmoke;
            rTrig29.CLK = Global.rData.gS0[29];
            if (rTrig29.Q)
            {
                uiScrollingText1.Text = uiSymbolButton37.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton27.FillDisableColor = (Global.rData.gS0[30] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton27.ForeDisableColor = Color.WhiteSmoke;
            rTrig30.CLK = Global.rData.gS0[30];
            if (rTrig30.Q)
            {
                uiScrollingText1.Text = uiSymbolButton27.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }

            uiSymbolButton38.FillDisableColor = (Global.rData.gS0[32] == true) ? Color.LightCoral : Color.DarkGray;
            uiSymbolButton38.ForeDisableColor = Color.WhiteSmoke;
            rTrig32.CLK = Global.rData.gS0[32];
            if (rTrig32.Q)
            {
                uiScrollingText1.Text = uiSymbolButton38.Text;
                //报警日志存储到数据库
                ralarmlog = new AlarmLogs(uiScrollingText1.Text, original);// 数据
                db.Insertable(ralarmlog).ExecuteCommand(); //都是参数化实现
            }
            
            #endregion
            //********************
            //*****日志管理*******
            //********************
            #region **********控件隐藏部分**************
            if (Global.IsLogin >= 1)
            {
                uiSymbolButton35.Visible = true;//显示删除日志按钮
                uiSymbolButton36.Visible = true;//显示插入日志按钮
            }
            else
            {
                uiSymbolButton35.Visible = false;//删除日志按钮
                uiSymbolButton36.Visible = false;//插入日志按钮
            }
            #endregion

            #region **********日志管理**************
            //记录日志触发
            rTrig31.CLK = Global.rData.gM2000[13];
            if (rTrig31.Q)
            {
                Array.Copy(dwsSource, 0, dwsSource, 1, dwsSource.Length - 1);//数组移动.
                dwsSource[0] = Global.rData.D1050;//记录实际密度;

                if (!backgroundWorker4.IsBusy)
                {
                    this.backgroundWorker4.RunWorkerAsync();//插入日志
                }
            }
            #endregion
            //********************
            //*****服务*******
            //********************
            #region **********服务**************
            uiLabel497.Text = "TopicPub1:data/" + original;//TopicPub1:data/PN
            uiLabel498.Text = "TopicSub2:cmd/" + original;//TopicSub2:cmd/PN
            uiLabel499.Text = "TopicPub3:result/" + original;//TopicPub3:result/PN
            uiLabel500.Text = "TopicSub1:data/" + original;//TopicSub1:data/PN
            uiLabel501.Text = "TopicPub2:cmd/" + original;//TopicPub2:cmd/PN
            uiLabel502.Text = "TopicSub3:result/" + original;//TopicSub3:result/PN
            uiLabel508.Text = "TopicPub4:plog/" + original;//TopicPub4:plog/PN
            uiLabel509.Text = "TopicPub5:recipe/" + original;//TopicPub5:recipe/PN
            #endregion
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (gButtonFlag == 1)
                return;

            uiComboBox1.SelectedIndex = Convert.ToInt32(Global.rData.D2605);//订单结束停止电机
            uiComboBox2.SelectedIndex = Convert.ToInt32(Global.rData.D2606);//加热检测方式
            uiComboBox3.SelectedIndex = Convert.ToInt32(Global.rData.D2607);//选择发料工艺
            uiComboBox32.SelectedIndex = Convert.ToInt32(Global.rData.D2602);//加热模式
            uiComboBox33.SelectedIndex = Convert.ToInt32(Global.rData.D2631);//剩料功能

            uiComboBox4.SelectedIndex = Convert.ToInt32(Global.rData.D2612);//吹扫加热使用蒸汽副阀
            uiComboBox5.SelectedIndex = Convert.ToInt32(Global.rData.D2613);//主加热使用蒸汽副阀
            uiComboBox6.SelectedIndex = Convert.ToInt32(Global.rData.D2614);//主加热使用空气主阀
            uiComboBox10.SelectedIndex = Convert.ToInt32(Global.rData.D2615);//吹扫加热使用空气副阀
            uiComboBox11.SelectedIndex = Convert.ToInt32(Global.rData.D2616);//吹扫加热使用大排气

            uiComboBox12.SelectedIndex = Convert.ToInt32(Global.rData.D2608);//底部清扫
            uiComboBox13.SelectedIndex = Convert.ToInt32(Global.rData.D2609);//旁通小排气小阀
            uiComboBox14.SelectedIndex = Convert.ToInt32(Global.rData.D2610);//旁通小排气大阀
            uiComboBox15.SelectedIndex = Convert.ToInt32(Global.rData.D2611);//减压时快速冷却

            uiComboBox20.SelectedIndex = Convert.ToInt32(Global.rData.D2618);//选择料斗上料方式
            uiComboBox21.SelectedIndex = Convert.ToInt32(Global.rData.D2619);//是否有DWS装置
            uiComboBox22.SelectedIndex = Convert.ToInt32(Global.rData.D2620);//是否有地上称重装置
            uiComboBox23.SelectedIndex = Convert.ToInt32(Global.rData.D2621);//是否有负压吸料
            uiComboBox24.SelectedIndex = Convert.ToInt32(Global.rData.D2622);//是否有原料称重装置
            uiComboBox25.SelectedIndex = Convert.ToInt32(Global.rData.D2623);//是否有二次发泡装置
            uiComboBox26.SelectedIndex = Convert.ToInt32(Global.rData.D2630);//称重仪表通讯方式(跟压缩气比例阀反馈一通道)

            uiComboBox19.SelectedIndex = Convert.ToInt32(Global.rData.D2624);//是否有桶体温度变送器
            uiComboBox18.SelectedIndex = Convert.ToInt32(Global.rData.D2625);//是否有安全门接近开关
            uiComboBox17.SelectedIndex = Convert.ToInt32(Global.rData.D2626);//使用排气阀控制压力
            uiComboBox16.SelectedIndex = Convert.ToInt32(Global.rData.D2617);//是否预热后打开出料门
            uiComboBox28.SelectedIndex = Convert.ToInt32(Global.rData.D2628);//蒸汽阀选择
            uiComboBox29.SelectedIndex = Convert.ToInt32(Global.rData.D2629);//是否有真空冷却装置
            uiComboBox30.SelectedIndex = Convert.ToInt32(Global.rData.D2284);//机型选择

            uiComboBox27.SelectedIndex = Convert.ToInt32(Global.rData.D2632);//恒压模式pid
            uiComboBox34.SelectedIndex = Convert.ToInt32(Global.rData.D2633);//恒温模式pid
        }

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            //单表分页
            //page.Clear();//此处不能添加此项，否者偶尔会报错    DataGridView报错:“System.IndexOutOfRangeException: 索引 0 没有值
            totalCount = 0;
            page = db.Queryable<PLog>().OrderByDescending(st => st.id).ToPageList(uiPagination1.ActivePage, uiPagination1.PageSize, ref totalCount);
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //日志数据显示
            uiPagination1.TotalCount = totalCount;
            uiDataGridView1.DataSource = page;
        }

        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            IniFile ini = new IniFile(@"C:\FangYuanData\Setting.ini");
            string Ip = ini.ReadString("IPC", "Ip", "");
            string Port = ini.ReadString("IPC", "Port", "");
            string MqttIp = ini.ReadString("Mqtt", "Ip", "");
            string MqttPort = ini.ReadString("Mqtt", "Port", "");
            string MqttUser = ini.ReadString("Mqtt", "User", "");
            string MqttPassword = ini.ReadString("Mqtt", "Password", "");

            HslMqtt.OpenConnect(MqttIp, Convert.ToInt32(MqttPort), MqttUser, MqttPassword);//  MQTT实例化

            HslMelsecMCBinary.OpenConnect(Ip, Convert.ToInt32(Port)); //三菱5U通讯实例化
        }

        private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = true;
        }

        private void backgroundWorker3_DoWork(object sender, DoWorkEventArgs e)
        {
            gButtonFlag = 1;
            Thread.Sleep(500);//设置采集周期
        }

        private void backgroundWorker3_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            gButtonFlag = 0;
        }

        private void backgroundWorker4_DoWork(object sender, DoWorkEventArgs e)
        {
            //插入日志记录
            PLog rlog;
            //string sql;
            DateTime datalog;
            string setWeightLog, actWeightLog, setDensityLog, actDensityLog, heatTimeLog, cycleLog, phdPressLog, phdTempLog, topPressLog, topTempLog, steamPressLog, airPressLog;
            //增加日志记录
            datalog = DateTime.Now;//系统时间显示
            setWeightLog = ControlAttribute.TextBoxRead(uiTextBox4, Global.rData.D1070.ToString());//设定重量
            actWeightLog = ControlAttribute.TextBoxRead(uiTextBox4, Global.rData.D1062.ToString());//入料重量
            setDensityLog = ControlAttribute.TextBoxRead(uiTextBox16, Global.rData.D1068.ToString());//设定密度
            actDensityLog = ControlAttribute.TextBoxRead(uiTextBox16, Global.rData.D1050.ToString());//实际密度
            heatTimeLog = ControlAttribute.TextBoxRead(uiTextBox10, (Convert.ToSingle(Global.rData.D1066) / 100).ToString());//加热时间
            cycleLog = ControlAttribute.TextBoxRead(uiTextBox10, (Convert.ToSingle(Global.rData.D1058) / 100).ToString());//周期
            phdPressLog = ControlAttribute.TextBoxRead(uiTextBox7, Global.rData.D1052.ToString());//管道压力
            phdTempLog = ControlAttribute.TextBoxRead(uiTextBox5, Global.rData.D1054.ToString());//管道温度
            topPressLog = ControlAttribute.TextBoxRead(uiTextBox7, Global.rData.D1074.ToString());//桶顶压力
            topTempLog = ControlAttribute.TextBoxRead(uiTextBox5, Global.rData.D1076.ToString());//桶顶温度
            steamPressLog = ControlAttribute.TextBoxRead(uiTextBox7, Global.rData.D1072.ToString());//蒸汽压力
            airPressLog = ControlAttribute.TextBoxRead(uiTextBox7, Global.rData.D1056.ToString());//空气压力

            rlog = new PLog(datalog, setWeightLog, actWeightLog, setDensityLog, actDensityLog, heatTimeLog, cycleLog, phdPressLog, phdTempLog,
                topPressLog, topTempLog, steamPressLog, airPressLog, original);// 数据

            db.Insertable(rlog).ExecuteCommand(); //都是参数化实现

            HslMqtt.pLogToMqtt(rlog);//发布日志数据到mqtt服务器
            //mqtt发布日志消息

        }

        private void backgroundWorker4_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            /*//单表分页
            int totalCount = 0;
            var page = db.Queryable<PLog>().OrderByDescending(st => st.id).ToPageList(uiPagination1.ActivePage, uiPagination1.PageSize, ref totalCount);
            uiPagination1.TotalCount = totalCount;

            uiDataGridView1.DataSource = page.ToList();
            */
            //刷新日志
            if (!backgroundWorker1.IsBusy)
            {
                this.backgroundWorker1.RunWorkerAsync();//刷新日志
            }
        }

        private void backgroundWorker5_DoWork(object sender, DoWorkEventArgs e)
        {
            //表中数据全部清空，清除，自增初始化
            db.DbMaintenance.TruncateTable<PLog>();
            Global.LogNet.WriteWarn(this.Name.ToString(), "删除所有日志记录!");
        }

        private void backgroundWorker5_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!backgroundWorker1.IsBusy)
            {
                this.backgroundWorker1.RunWorkerAsync();//刷新日志
            }
        }
        private void backgroundWorker6_DoWork(object sender, DoWorkEventArgs e)
        {
            //数据库文件初始化
            //创建数据库，不存在：创建，  存在：不会重复创建
            //会根据连接字符串中的数据库进行创建
            var db = SqlSugarHelper.Db;
            //建库：如果不存在创建数据库存在不会重复创建 
            db.DbMaintenance.CreateDatabase(); // 注意 ：Oracle和个别国产库需不支持该方法，需要手动建库 
            //创建日志记录表：根据实体类CodeFirstTable1  (所有数据库都支持)    
            db.CodeFirst.InitTables(typeof(PLog));//这样一个表就能成功创建了 

            //创建报警日志记录表：根据实体类CodeFirstTable1  (所有数据库都支持)    
            db.CodeFirst.InitTables(typeof(AlarmLogs));//这样一个表就能成功创建了 


            //报表浏览器初始化
            IniFile inirp = new IniFile(@"C:\FangYuanData\Setting.ini");
            string CompanyName = inirp.ReadString("Company", "CompanyName", "");
            /*this.reportViewer1.LocalReport.DataSources.Clear();
            ReportDataSource rds = new ReportDataSource("DataLog", reportList);
            this.reportViewer1.LocalReport.DataSources.Add(rds);*/
            ReportParameter rp = new ReportParameter("RP_CompanyName", CompanyName);
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });//传入固定参数，不可变动

        }

        private void backgroundWorker6_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //plc初始化
            if (!backgroundWorker2.IsBusy)
            {
                this.backgroundWorker2.RunWorkerAsync();//PLC初始化
            }
            //刷新日志
            if (!backgroundWorker1.IsBusy)
            {
                this.backgroundWorker1.RunWorkerAsync();//刷新日志
            }
            //软件授权
            if (!backgroundWorker8.IsBusy)
            {
                this.backgroundWorker8.RunWorkerAsync();//软件授权
            }
            //uiListBox2.Items.Clear();//清除历史报警控件数据
            uiDatePicker1.Text = DateTime.Now.ToString("yyyy-MM");//报表日期初始化显示
        }

        private void backgroundWorker7_DoWork(object sender, DoWorkEventArgs e)
        {
            //报表浏览器查看
            reportList.Clear();
            DateTime NowValue = Convert.ToDateTime(uiDatePicker1.Value);//本月1号
            DateTime NextValue = Convert.ToDateTime(DateTime.Parse(NowValue.ToString("yyyy-MM-01")).AddMonths(1).ToShortDateString());//下月1号

            reportList = db.Queryable<PLog>().Where(it => it.dateLog >= NowValue && it.dateLog <= NextValue).ToList();

            //reportList = pagedata.ToList();
            this.reportViewer1.LocalReport.DataSources.Clear();
            ReportDataSource rds = new ReportDataSource("DataLog", reportList);
            this.reportViewer1.LocalReport.DataSources.Add(rds);

        }

        private void backgroundWorker7_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.reportViewer1.RefreshReport();
        }

        private void backgroundWorker8_DoWork(object sender, DoWorkEventArgs e)
        {
            //授权
            // Decrypt the bytes to a string.
            original = Global.GetCpuInfo();//授权码

            string lic = @"C:\FangYuanData\license.lic";
            IniFile ini = new IniFile(lic);
            string strEncrypted = ini.ReadString("License", "Encrypted", "");
            string strKey = ini.ReadString("License", "Key", "");
            string strIV = ini.ReadString("License", "IV", "");
            try
            {
                if (Convert.FromBase64String(strKey).Length == 32 && Convert.FromBase64String(strIV).Length == 16)
                {
                    string roundtrip = Global.DecryptStringFromBytes_Aes(Convert.FromBase64String(strEncrypted), Convert.FromBase64String(strKey), Convert.FromBase64String(strIV));
                    if (original == roundtrip)
                    {
                        if (Settings.Default.Language == 0)  // 中文
                        {
                            ActivationStatus = "已激活";
                        }
                        else if (Settings.Default.Language == 1) // 英文
                        {
                            ActivationStatus = "Activated";
                        }
                        LicenseStatus = true;//激活状态
                    }
                    else
                    {
                        if (Settings.Default.Language == 0)  // 中文
                        {
                            ActivationStatus = "未激活";
                            UIMessageDialog.ShowMessageDialog("未激活,只能运行2个小时!", UILocalize.InfoTitle, false, Style);
                        }
                        else if (Settings.Default.Language == 1) // 英文
                        {
                            ActivationStatus = "not activated";
                            UIMessageDialog.ShowMessageDialog("Can only run for 2 hours!", UILocalize.InfoTitle, false, Style);
                        }
                        LicenseStatus = false;//未激活状态
                    }
                }
                else
                {
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        ActivationStatus = "未激活";
                        UIMessageDialog.ShowMessageDialog("未激活,只能运行2个小时!", UILocalize.InfoTitle, false, Style);
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        ActivationStatus = "not activated";
                        UIMessageDialog.ShowMessageDialog("Can only run for 2 hours!", UILocalize.InfoTitle, false, Style);
                    }
                    LicenseStatus = false;//未激活状态
                }
            }
            catch (Exception)
            {
                if (Settings.Default.Language == 0)  // 中文
                {
                    ActivationStatus = "未激活";
                    UIMessageDialog.ShowMessageDialog("未激活,只能运行2个小时!", UILocalize.InfoTitle, false, Style);
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    ActivationStatus = "not activated";
                    UIMessageDialog.ShowMessageDialog("Can only run for 2 hours!", UILocalize.InfoTitle, false, Style);
                }
                LicenseStatus = false;//未激活状态
            }
        }

        private void backgroundWorker8_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {

        }

        private void uiDatePicker1_ValueChanged(object sender, DateTime value)
        {
            //报表显示
            if (!backgroundWorker7.IsBusy)
            {
                this.backgroundWorker7.RunWorkerAsync();//报表加载
            }
        }

        private void uiPagination1_PageChanged(object sender, object pagingSource, int pageIndex, int count)
        {
            //连接数据库，通过模拟数据来实现
            //一般通过ORM的分页去取数据来填充
            //pageIndex：第几页，和界面对应，从1开始，取数据可能要用pageIndex - 1
            //count：单页数据量，也就是PageSize值
            //单表分页
            /*int totalCount = 0;
            var page = db.Queryable<PLog>().OrderByDescending(st => st.id).ToPageList(pageIndex, count, ref totalCount);
            uiPagination1.TotalCount = totalCount;

            uiDataGridView1.DataSource = page.ToList();*/
            //刷新日志
            if (!backgroundWorker1.IsBusy)
            {
                this.backgroundWorker1.RunWorkerAsync();//刷新日志
            }
        }

        private void uiTabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            uiMarkLabel4.Text = uiTabControl1.SelectedTab.Text;
        }

        private void uiTabControlMenu1_SelectedIndexChanged(object sender, EventArgs e)
        {
            uiMarkLabel4.Text = uiTabControlMenu1.SelectedTab.Text;
        }

        private void uiTabControlMenu2_SelectedIndexChanged(object sender, EventArgs e)
        {
            uiMarkLabel4.Text = uiTabControlMenu2.SelectedTab.Text;
        }

        private void uiTabControlMenu3_SelectedIndexChanged(object sender, EventArgs e)
        {
            uiMarkLabel4.Text = uiTabControlMenu3.SelectedTab.Text;
            //
            //报警历史显示
            //int totalCount = 0;
            if (uiTabControlMenu3.SelectedIndex == 1)//报警画面
            {
                var alarmPage = db.Queryable<AlarmLogs>().OrderByDescending(st => st.id).Take(1000).ToList();
                List<string> list = new List<string>();
                for (int i = 0; i < alarmPage.Count; i++)
                {
                    list.Add(alarmPage[i].dateLog.ToString() + alarmPage[i].alarmNote);
                }

                uiListBox2.DataSource = list;
            }
            else if (uiTabControlMenu3.SelectedIndex == 2)//操作日志记录
            {
                // 系统日志记录文件创建
                // 该source可以是本地读取的文件，也可以是网络发送过来的数据
                string path = @"C:\FangYuanData\Logs\Logs_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                if (File.Exists(path))
                {
                    string source = Encoding.UTF8.GetString(File.ReadAllBytes(path));   // 传入路径
                    logNetAnalysisControl1.SetLogNetSource(source);
                }
            }
        }

        private void uiSymbolButton29_Click(object sender, EventArgs e)
        {
            bool v = false;
            if (Settings.Default.Language == 0)  // 中文
            {
                v = UIMessageDialog.ShowMessageDialog("保存配方?", UILocalize.InfoTitle, true, Style);
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                v = UIMessageDialog.ShowMessageDialog("Save recipe parameters?", UILocalize.InfoTitle, true, Style);
            }
            string path = @"C:\FangYuanData\Recipes\";
            if (v == true)
            {
                List<Recipe> recipeList = new List<Recipe>();
                //recipeList.Clear();
                Recipe recipe;
                string idname;
                idname = uiTextBox48.Text + "-" + uiTextBox49.Text;
                recipe = new Recipe(idname, uiTextBox48.Text, uiTextBox49.Text, uiTextBox50.Text, 
                    uiTextBox178.Text, uiTextBox179.Text, uiTextBox180.Text, uiTextBox181.Text, uiTextBox182.Text,
                    uiComboBox7.SelectedIndex, uiComboBox8.SelectedIndex, uiComboBox9.SelectedIndex, uiComboBox31.SelectedIndex, original);// 数据
                recipeList.Add(recipe);
                if (File.Exists(path + idname + ".xml"))
                {
                    //存在 
                    bool w = false;
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        w = UIMessageDialog.ShowMessageDialog("覆盖配方?", UILocalize.InfoTitle, true, Style);
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        w = UIMessageDialog.ShowMessageDialog("Overlay formulation parameters?", UILocalize.InfoTitle, true, Style);
                    }
                    if (w == true)
                    {
                        RecipeXML.GenerateRecipeXMLFile(path + idname + ".xml", recipeList); // 保存
                        HslMqtt.recipeToMqtt(recipe);//发布配方数据
                    }
                }
                else
                {
                    RecipeXML.GenerateRecipeXMLFile(path + idname + ".xml", recipeList); // 保存
                    HslMqtt.recipeToMqtt(recipe);//发布配方数据
                }
            }
            //刷新列表
            DirectoryInfo folder = new DirectoryInfo(path);
            uiListBox1.Items.Clear();
            foreach (FileInfo file in folder.GetFiles("*.xml"))
            {
                uiListBox1.Items.Add(file.Name);
                //Console.WriteLine(file.FullName);
            }
            //uiListBox1.Refresh();//刷新
            //Console.WriteLine(v);
        }

        private void uiSymbolButton30_Click(object sender, EventArgs e)
        {
            bool v = false;
            if (Settings.Default.Language == 0)  // 中文
            {
                v = UIMessageDialog.ShowMessageDialog("加载配方?", UILocalize.InfoTitle, true, Style);
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                v = UIMessageDialog.ShowMessageDialog("Loading recipe parameters?", UILocalize.InfoTitle, true, Style);
            }
            string path = @"C:\FangYuanData\Recipes\";
            if (v == true)
            {
                if (File.Exists(path + uiListBox1.Text))
                {
                    //存在 
                    //List<Recipe> recipeList = new List<Recipe>();
                    //recipeList.Clear();
                    RecipeXML.ReadRecipeXMLFile(path + uiListBox1.Text, out List<Recipe> recipeList);
                    foreach (var item in recipeList)
                    {
                        uiTextBox48.Text = item.epsName;
                        uiTextBox49.Text = item.setDensity;
                        uiTextBox50.Text = item.setWeight;
                        uiTextBox178.Text = item.setPress;
                        uiTextBox179.Text = item.setTemp;
                        uiTextBox180.Text = item.setExhaust;
                        uiTextBox181.Text = item.setMaxHeatTime;
                        uiTextBox182.Text = item.setMinHeatTime;
                        uiComboBox7.SelectedIndex = item.setSensor;
                        uiComboBox8.SelectedIndex = item.setHeatingMode;
                        uiComboBox9.SelectedIndex = item.setSmallValve;
                        uiComboBox31.SelectedIndex = item.setBigValve;
                    }

                    if (gItemIndex == -1 || gItemIndex == 1 || gItemIndex == 2 || gItemIndex == 3)
                    {
                        gItemIndex = 0;//加载配方步骤显示
                    }
                    if (gItemIndex == 5)
                    {
                        gItemIndex = -1;//步骤显示
                    }
                }
                else
                {
                    if (Settings.Default.Language == 0)  // 中文
                    {
                        UIMessageTip.ShowWarning("没有选择配方文件 - 警告!");   //
                    }
                    else if (Settings.Default.Language == 1) // 英文
                    {
                        UIMessageTip.ShowWarning("No recipe file selected - warning!");   //
                    }
                }
            }
            //uiListBox1.Refresh();//刷新
            //Console.WriteLine(v);
        }

        private void uiSymbolButton31_Click(object sender, EventArgs e)
        {
            if (Global.IsLogin >= 1)
            {
                bool v = false;
                if (Settings.Default.Language == 0)  // 中文
                {
                    v = UIMessageDialog.ShowMessageDialog("删除配方?", UILocalize.InfoTitle, true, Style);
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    v = UIMessageDialog.ShowMessageDialog("Delete recipe parameters?", UILocalize.InfoTitle, true, Style);
                }
                string path = @"C:\FangYuanData\Recipes\";
                if (v == true)
                {
                    if (uiListBox1.Text != null)
                    {
                        //存在 
                        File.Delete(path + uiListBox1.Text);
                        Global.LogNet.WriteWarn(this.Name.ToString(), "删除配方:" + path + uiListBox1.Text);
                    }
                    else
                    {
                        if (Settings.Default.Language == 0)  // 中文
                        {
                            UIMessageTip.ShowWarning("没有选择配方文件 - 警告!");   //
                        }
                        else if (Settings.Default.Language == 1) // 英文
                        {
                            UIMessageTip.ShowWarning("No recipe file selected - warning!");   //
                        }
                    }
                }
                //刷新列表
                DirectoryInfo folder = new DirectoryInfo(path);
                uiListBox1.Items.Clear();
                foreach (FileInfo file in folder.GetFiles("*.xml"))
                {
                    uiListBox1.Items.Add(file.Name);
                    //Console.WriteLine(file.FullName);
                }
                //Console.WriteLine(v);
            }
            else
            {
                if (Settings.Default.Language == 0)  // 中文
                {
                    ShowErrorTip("登录权限不足!");
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    ShowErrorTip("Insufficient login privileges!");
                }
            }
        }

        private void uiSymbolButton32_Click(object sender, EventArgs e)
        {
            bool v = false;
            if (Settings.Default.Language == 0)  // 中文
            {
                v = UIMessageDialog.ShowMessageDialog("上传设备参数!", UILocalize.InfoTitle, true, Style);
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                v = UIMessageDialog.ShowMessageDialog("Upload equipment parameters!", UILocalize.InfoTitle, true, Style);
            }
            if (v == true)
            {
                //uiTextBox48.Text = uiTextBox15.Text;//eps品牌
                uiTextBox48.Text = Global.rData.D1500.ToString();//eps品牌
                uiTextBox49.Text = ControlAttribute.TextBoxRead(uiTextBox49, Global.rData.D1046.ToString());//发泡密度
                uiTextBox50.Text = ControlAttribute.TextBoxRead(uiTextBox50, Global.rData.D2000.ToString());//设定重量
                uiTextBox178.Text = ControlAttribute.TextBoxRead(uiTextBox178, Global.rData.D2008.ToString());//设定压力
                uiTextBox179.Text = ControlAttribute.TextBoxRead(uiTextBox179, Global.rData.D2010.ToString());//设定温度
                uiTextBox180.Text = ControlAttribute.TextBoxRead(uiTextBox180, Global.rData.D2050.ToString());//排气比例阀开度
                uiTextBox181.Text = ControlAttribute.TextBoxRead(uiTextBox181, (Convert.ToSingle(Global.rData.D2204) / 100).ToString());//最大加热时间
                uiTextBox182.Text = ControlAttribute.TextBoxRead(uiTextBox182, (Convert.ToSingle(Global.rData.D2202) / 100).ToString());//最大加热时间
                uiComboBox7.SelectedIndex = Convert.ToInt32(Global.rData.D2603);//料位传感器选择
                uiComboBox8.SelectedIndex = Convert.ToInt32(Global.rData.D2602);//加热模式
                uiComboBox9.SelectedIndex = Convert.ToInt32(Global.rData.D2609);//旁通小排气小阀
                uiComboBox31.SelectedIndex = Convert.ToInt32(Global.rData.D2610);//旁通小排气大阀
            }
        }

        private void uiSymbolButton33_Click(object sender, EventArgs e)
        {
            bool v = false;
            if (Settings.Default.Language == 0)  // 中文
            {
                v = UIMessageDialog.ShowMessageDialog("下载配方参数!", UILocalize.InfoTitle, true, Style);
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                v = UIMessageDialog.ShowMessageDialog("Download recipe to device!", UILocalize.InfoTitle, true, Style);
            }
            if (v == true)
            {
                //uiTextBox15.Text = uiTextBox48.Text;//eps品牌
                HslMelsecMCBinary.WriteString("D1500", uiTextBox48.Text.ToString(), 20);//eps品牌
                HslMelsecMCBinary.WriteSingle("D1046", Convert.ToSingle(uiTextBox49.Text));//发泡密度
                HslMelsecMCBinary.WriteSingle("D2000", Convert.ToSingle(uiTextBox50.Text));//设定重量
                HslMelsecMCBinary.WriteSingle("D2008", Convert.ToSingle(uiTextBox178.Text));//设定压力
                HslMelsecMCBinary.WriteSingle("D2010", Convert.ToSingle(uiTextBox179.Text));//设定温度
                HslMelsecMCBinary.WriteSingle("D2050", Convert.ToSingle(uiTextBox180.Text));//排气比例阀开度
                HslMelsecMCBinary.WriteUInt32("D2204", Convert.ToUInt32(Convert.ToSingle(uiTextBox181.Text)), 100);//最大加热时间
                HslMelsecMCBinary.WriteUInt32("D2202", Convert.ToUInt32(Convert.ToSingle(uiTextBox182.Text)), 100);//最小加热时间
                HslMelsecMCBinary.WriteUInt16("D2603", Convert.ToUInt16(uiComboBox7.SelectedIndex));//料位传感器选择
                HslMelsecMCBinary.WriteUInt16("D2602", Convert.ToUInt16(uiComboBox8.SelectedIndex));//加热模式
                HslMelsecMCBinary.WriteUInt16("D2609", Convert.ToUInt16(uiComboBox9.SelectedIndex));//旁通小排气小阀
                HslMelsecMCBinary.WriteUInt16("D2610", Convert.ToUInt16(uiComboBox31.SelectedIndex));//旁通小排气大阀

                if (gItemIndex == -1 || gItemIndex == 0 || gItemIndex == 2 || gItemIndex == 3)
                {
                    gItemIndex = 1;//加载配方步骤显示
                }
                if (gItemIndex == 5)
                {
                    gItemIndex = -1;//步骤显示
                }
            }
            //Console.WriteLine(v);
        }

        private void uiComboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiComboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiListBox1_Load(object sender, EventArgs e)
        {
            string path = @"C:\FangYuanData\Recipes\";
            DirectoryInfo folder = new DirectoryInfo(path);
            uiListBox1.Items.Clear();
            foreach (FileInfo file in folder.GetFiles("*.xml"))
            {
                uiListBox1.Items.Add(file.Name);
                //Console.WriteLine(file.FullName);
            }
        }

        private void uiTextBox49_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox48_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox50_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox178_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox179_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox180_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox15_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox181_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox182_TextChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiComboBox9_SelectedIndexChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiComboBox31_SelectedIndexChanged(object sender, EventArgs e)
        {
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiComboBox7_Load(object sender, EventArgs e)
        {
            uiComboBox7.SelectedIndex = 0;
        }

        private void uiComboBox8_Load(object sender, EventArgs e)
        {
            uiComboBox8.SelectedIndex = 0;
        }

        private void uiComboBox9_Load(object sender, EventArgs e)
        {
            uiComboBox9.SelectedIndex = 1;
        }

        private void uiComboBox31_Load(object sender, EventArgs e)
        {
            uiComboBox31.SelectedIndex = 0;
        }

        private void uiSymbolButton35_Click(object sender, EventArgs e)
        {
            bool v = false;
            if (Settings.Default.Language == 0)  // 中文
            {
                v = UIMessageDialog.ShowMessageDialog("删除所有日志?", UILocalize.InfoTitle, true, Style);
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                v = UIMessageDialog.ShowMessageDialog("Clear all logs?", UILocalize.InfoTitle, true, Style);
            }
            //Console.WriteLine(v);
            if (v == true)
            {
                if (!backgroundWorker5.IsBusy)
                {
                    this.backgroundWorker5.RunWorkerAsync();//刷新日志
                }
            }
            
        }
        private void uiSymbolButton36_Click(object sender, EventArgs e)
        {
            if (!backgroundWorker4.IsBusy)
            {
                this.backgroundWorker4.RunWorkerAsync();//插入日志
            }
        }

        private void uiHeaderButton2_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2002", !Global.rData.gM2000[2]);
            if (Global.rData.gM2000[2] == false)
            {
                HslMelsecMCBinary.WriteBool("M2003", true);
                if (Global.rData.D2619 == 1)
                {
                    HslMelsecMCBinary.WriteBool("M2012", true);
                }
            }
        }

        private void uiHeaderButton1_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2000", !Global.rData.gM2000[0]);
            if (Global.rData.gS0[31] != true && Global.rData.gM2000[0] == false)
            {
                HslMelsecMCBinary.WriteBool("M2001", true);
            }
        }

        private void uiHeaderButton3_Click(object sender, EventArgs e)
        {
            if (Global.rData.gS0[31] == false)//没锁机
            {
                HslMelsecMCBinary.WriteBool("M2001", !Global.rData.gM2000[1]);
            }
            else
            {
                ShowErrorTip(uiScrollingText1.Text);//锁机中显示
            }
        }

        private void uiHeaderButton4_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2003", !Global.rData.gM2000[3]);
        }

        private void uiHeaderButton5_Click(object sender, EventArgs e)
        {
            if (Global.rData.D2619 == 1)
            {
                HslMelsecMCBinary.WriteBool("M2012", !Global.rData.gM2000[12]);
            }
            else
            {
                if (Settings.Default.Language == 0)  // 中文
                {
                    ShowErrorTip("未经授权!");
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    ShowErrorTip("Unauthorized!");
                }
            }
        }

        private void uiHeaderButton6_Click(object sender, EventArgs e)
        {
            if (Global.rData.D2619 == 1)
            {
                HslMelsecMCBinary.WriteBool("M2016", !Global.rData.gM2000[16]);
            }
            else
            {
                if (Settings.Default.Language == 0)  // 中文
                {
                    ShowErrorTip("未经授权!");
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    ShowErrorTip("Unauthorized!");
                }
            }
        }

        private void uiHeaderButton10_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2006", !Global.rData.gM2000[6]);
            HslMelsecMCBinary.WriteBool("M2007", true);
        }

        private void uiHeaderButton9_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2011", true);
        }

        private void uiHeaderButton7_MouseDown(object sender, MouseEventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2004", true);
        }

        private void uiHeaderButton7_MouseUp(object sender, MouseEventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2004", false);
        }

        private void uiHeaderButton8_MouseDown(object sender, MouseEventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2005", true);
        }

        private void uiHeaderButton8_MouseUp(object sender, MouseEventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2005", false);
        }

        private void toolStripMenuItemzh_CN_Click(object sender, EventArgs e)
        {
            if (Settings.Default.Language != 0)
            {
                LanguageRESX.Resource_zh_CN();
                UIMessageTip.ShowOk("Please restart the application!");
            }
        }

        private void toolStripMenuItemen_US_Click(object sender, EventArgs e)
        {
            if (Settings.Default.Language != 1)
            {
                LanguageRESX.Resource_en_US();
                UIMessageTip.ShowOk("请重启应用程序!");
            }
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M30", !Global.rData.gM0[30]);
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M37", !Global.rData.gM0[37]);
        }

        private void uiButton3_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M34", !Global.rData.gM0[34]);
        }

        private void uiButton4_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M35", !Global.rData.gM0[35]);
        }

        private void uiButton5_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M20", !Global.rData.gM0[20]);
        }

        private void uiButton6_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M40", !Global.rData.gM0[40]);
        }

        private void uiButton7_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M44", !Global.rData.gM0[44]);
        }

        private void uiButton28_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M0", !Global.rData.gM0[0]);
        }

        private void uiButton29_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M2", !Global.rData.gM0[2]);
        }

        private void uiButton31_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M3", !Global.rData.gM0[3]);
        }

        private void uiButton33_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M4", !Global.rData.gM0[4]);
        }

        private void uiButton35_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M1", !Global.rData.gM0[1]);
        }

        private void uiButton34_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M22", !Global.rData.gM0[22]);
        }

        private void uiButton30_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M5", !Global.rData.gM0[5]);
        }

        private void uiButton32_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M7", !Global.rData.gM0[7]);
        }

        private void uiButton37_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M10", !Global.rData.gM0[10]);
        }

        private void uiButton38_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M11", !Global.rData.gM0[11]);
        }

        private void uiButton36_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M12", !Global.rData.gM0[12]);
        }

        private void uiButton39_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M13", !Global.rData.gM0[13]);
        }

        private void uiButton40_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M14", !Global.rData.gM0[14]);
        }

        private void uiButton41_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M24", !Global.rData.gM0[24]);
        }

        private void uiButton42_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M21", !Global.rData.gM0[21]);
        }

        private void uiButton43_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M43", !Global.rData.gM0[43]);
        }

        private void uiButton44_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M16", !Global.rData.gM0[16]);
        }

        private void uiButton45_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M15", !Global.rData.gM0[15]);
        }

        private void uiButton46_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M26", !Global.rData.gM0[26]);
        }

        private void uiButton47_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M17", !Global.rData.gM0[17]);
        }

        private void uiButton48_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M23", !Global.rData.gM0[23]);
        }

        private void uiButton50_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M36", !Global.rData.gM0[36]);
        }

        private void uiButton49_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M42", !Global.rData.gM0[42]);
        }

        private void uiButton51_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M33", !Global.rData.gM0[33]);
        }

        private void uiButton52_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M30", !Global.rData.gM0[30]);
        }

        private void uiButton53_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M27", !Global.rData.gM0[27]);
        }

        private void uiButton54_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M37", !Global.rData.gM0[37]);
        }

        private void uiButton55_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M34", !Global.rData.gM0[34]);
        }

        private void uiButton56_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M35", !Global.rData.gM0[35]);
        }

        private void uiButton57_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M20", !Global.rData.gM0[20]);
        }

        private void uiButton58_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M40", !Global.rData.gM0[40]);
        }

        private void uiButton60_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M32", !Global.rData.gM0[32]);
        }

        private void uiButton61_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M44", !Global.rData.gM0[44]);
        }

        private void uiButton62_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M41", !Global.rData.gM0[41]);
        }

        private void uiButton63_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M31", !Global.rData.gM0[31]);
        }

        private void uiButton64_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M6", !Global.rData.gM0[6]);
        }

        private void uiButton59_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M25", !Global.rData.gM0[25]);
        }

        private void uiButton65_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M45", !Global.rData.gM0[45]);
        }

        private void uiButton66_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M46", !Global.rData.gM0[46]);
        }

        private void uiButton67_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M47", !Global.rData.gM0[47]);
        }

        private void uiButton12_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M50", !Global.rData.gM0[50]);
        }

        private void uiButton13_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M51", !Global.rData.gM0[51]);
        }

        private void uiButton14_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M52", !Global.rData.gM0[52]);
        }

        private void uiButton15_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M53", !Global.rData.gM0[53]);
        }

        private void uiButton16_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M54", !Global.rData.gM0[54]);
        }

        private void uiButton17_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M55", !Global.rData.gM0[55]);
        }

        private void uiButton18_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M56", !Global.rData.gM0[56]);
        }

        private void uiButton19_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M57", !Global.rData.gM0[57]);
        }

        private void uiButton20_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M60", !Global.rData.gM0[60]);
        }

        private void uiButton21_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M61", !Global.rData.gM0[61]);
        }

        private void uiButton22_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M62", !Global.rData.gM0[62]);
        }

        private void uiButton23_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M63", !Global.rData.gM0[63]);
        }

        private void uiButton24_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M64", !Global.rData.gM0[64]);
        }

        private void uiButton25_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M65", !Global.rData.gM0[65]);
        }

        private void uiButton26_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M66", !Global.rData.gM0[66]);
        }

        private void uiButton27_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M67", !Global.rData.gM0[67]);
        }

        private void uiButton8_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M100", !Global.rData.gM100[0]);
        }

        private void uiButton9_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M102", !Global.rData.gM100[2]);
        }

        private void uiButton10_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M101", !Global.rData.gM100[1]);
        }

        private void uiButton11_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteBool("M103", !Global.rData.gM100[3]);
        }

        private void uiButton68_Click(object sender, EventArgs e)
        {
            HslMelsecMCBinary.WriteUInt32("D1110", 0);
            HslMelsecMCBinary.WriteSingle("D1036", 0);
        }
        private void uiComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2605", this.backgroundWorker3);
        }

        private void uiComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2606", this.backgroundWorker3);
        }

        private void uiComboBox32_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2602", this.backgroundWorker3);
        }

        private void uiComboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2607", this.backgroundWorker3);
        }

        private void uiComboBox33_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2631", this.backgroundWorker3);
        }

        private void uiComboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2612", this.backgroundWorker3);
        }

        private void uiComboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2613", this.backgroundWorker3);
        }

        private void uiComboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2614", this.backgroundWorker3);
        }

        private void uiComboBox10_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2615", this.backgroundWorker3);
        }

        private void uiComboBox11_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2616", this.backgroundWorker3);
        }

        private void uiComboBox12_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2608", this.backgroundWorker3);
        }

        private void uiComboBox13_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2609", this.backgroundWorker3);
        }

        private void uiComboBox14_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2610", this.backgroundWorker3);
        }

        private void uiComboBox15_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2611", this.backgroundWorker3);
        }

        private void uiComboBox20_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2618", this.backgroundWorker3);
        }

        private void uiComboBox21_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2619", this.backgroundWorker3);
            if (((UIComboBox)sender).SelectedIndex == 0)
            {
                HslMelsecMCBinary.WriteBool("M2012", false);//关闭dws
                HslMelsecMCBinary.WriteBool("M2016", false);//关闭dws反馈
            }
        }

        private void uiComboBox22_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2620", this.backgroundWorker3);
        }

        private void uiComboBox23_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2621", this.backgroundWorker3);
        }

        private void uiComboBox24_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2622", this.backgroundWorker3);
        }

        private void uiComboBox25_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2623", this.backgroundWorker3);
        }

        private void uiComboBox26_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2630", this.backgroundWorker3);
        }

        private void uiComboBox27_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2632", this.backgroundWorker3);
        }

        private void uiComboBox34_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2633", this.backgroundWorker3);
        }

        private void uiComboBox19_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2624", this.backgroundWorker3);
        }

        private void uiComboBox18_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2625", this.backgroundWorker3);
        }

        private void uiComboBox17_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2626", this.backgroundWorker3);
        }

        private void uiComboBox16_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2617", this.backgroundWorker3);
        }

        private void uiComboBox28_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2628", this.backgroundWorker3);
        }

        private void uiComboBox29_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2629", this.backgroundWorker3);
        }

        private void uiComboBox30_SelectedIndexChanged(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.ComboBoxWriteUInt16((UIComboBox)sender, "D2284", this.backgroundWorker3);
        }

        private void uiTextBox1_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2000", this.backgroundWorker3);
;        }

        private void uiTextBox2_Enter(object sender, EventArgs e)
        {
            //KeyboardClass.OpenNumberBoard(this.uiTextBox2);
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2010", this.backgroundWorker3);
        }

        private void uiTextBox6_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2008", this.backgroundWorker3);
        }

        private void uiTextBox23_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2050", this.backgroundWorker3);
        }

        private void uiTextBox20_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2204", this.backgroundWorker3, 100);
        }

        private void uiTextBox18_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2300", this.backgroundWorker3);
        }

        private void uiTextBox19_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt16((UITextBox)sender, "D2600", this.backgroundWorker3);
        }

        private void uiTextBox21_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2326", this.backgroundWorker3, 100);
        }

        private void uiTextBox48_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenStringBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox49_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox50_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox178_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox179_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox180_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox181_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox182_Enter(object sender, EventArgs e)
        {
            KeyboardClass.OpenNumberBoard((UITextBox)sender);
            Settings.Default.Save();//使用Save方法保存更改
        }

        private void uiTextBox29_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2316", this.backgroundWorker3, 100);
        }

        private void uiTextBox40_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2062", this.backgroundWorker3);
        }

        private void uiTextBox42_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2112", this.backgroundWorker3);
        }

        private void uiTextBox44_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2050", this.backgroundWorker3);
        }

        private void uiTextBox46_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2036", this.backgroundWorker3);
        }

        private void uiTextBox30_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2318", this.backgroundWorker3, 100);
        }

        private void uiTextBox31_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2206", this.backgroundWorker3, 100);
        }

        private void uiTextBox32_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2208", this.backgroundWorker3, 100);
        }

        private void uiTextBox33_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2210", this.backgroundWorker3, 100);
        }

        private void uiTextBox34_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2252", this.backgroundWorker3, 100);
        }

        private void uiTextBox35_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2220", this.backgroundWorker3, 100);
        }

        private void uiTextBox36_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2302", this.backgroundWorker3, 100);
        }

        private void uiTextBox37_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2304", this.backgroundWorker3, 100);
        }

        private void uiTextBox38_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2322", this.backgroundWorker3, 100);
        }

        private void uiTextBox39_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2324", this.backgroundWorker3, 100);
        }

        private void uiTextBox51_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2016", this.backgroundWorker3);
        }

        private void uiTextBox52_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2308", this.backgroundWorker3, 100);
        }

        private void uiTextBox54_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2014", this.backgroundWorker3);
        }

        private void uiTextBox53_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2128", this.backgroundWorker3);
        }

        private void uiTextBox55_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2130", this.backgroundWorker3);
        }

        private void uiTextBox56_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2038", this.backgroundWorker3);
        }

        private void uiTextBox137_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2802", this.backgroundWorker3);
        }

        private void uiTextBox136_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2806", this.backgroundWorker3);
        }

        private void uiTextBox135_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2810", this.backgroundWorker3);
        }

        private void uiTextBox126_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2800", this.backgroundWorker3);
        }

        private void uiTextBox125_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2804", this.backgroundWorker3);
        }

        private void uiTextBox138_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2808", this.backgroundWorker3);
        }

        private void uiTextBox120_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2306", this.backgroundWorker3, 100);
        }

        private void uiTextBox119_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2212", this.backgroundWorker3, 100);
        }

        private void uiTextBox130_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2216", this.backgroundWorker3, 100);
        }

        private void uiTextBox129_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2214", this.backgroundWorker3, 100);
        }

        private void uiTextBox103_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2268", this.backgroundWorker3, 100);
        }

        private void uiTextBox102_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2270", this.backgroundWorker3, 100);
        }

        private void uiTextBox101_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2288", this.backgroundWorker3, 100);
        }

        private void uiTextBox100_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2290", this.backgroundWorker3, 100);
        }

        private void uiTextBox99_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2292", this.backgroundWorker3, 100);
        }

        private void uiTextBox98_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2294", this.backgroundWorker3, 100);
        }

        private void uiTextBox97_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2314", this.backgroundWorker3, 100);
        }

        private void uiTextBox96_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2312", this.backgroundWorker3, 100);
        }

        private void uiTextBox95_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2296", this.backgroundWorker3, 100);
        }

        private void uiTextBox94_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2298", this.backgroundWorker3, 100);
        }

        private void uiTextBox93_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2280", this.backgroundWorker3, 100);
        }

        private void uiTextBox92_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt16((UITextBox)sender, "D2601", this.backgroundWorker3);
        }

        private void uiTextBox91_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2002", this.backgroundWorker3);
        }

        private void uiTextBox104_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2004", this.backgroundWorker3);
        }

        private void uiTextBox90_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2114", this.backgroundWorker3);
        }

        private void uiTextBox105_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2116", this.backgroundWorker3);
        }

        private void uiTextBox106_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2282", this.backgroundWorker3, 100);
        }

        private void uiTextBox127_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2126", this.backgroundWorker3);
        }

        private void uiTextBox128_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2018", this.backgroundWorker3);
        }

        private void uiTextBox183_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2330", this.backgroundWorker3, 100);
        }

        private void uiTextBox184_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2332", this.backgroundWorker3, 100);
        }

        private void uiTextBox124_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2320", this.backgroundWorker3);
        }

        private void uiTextBox70_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2254", this.backgroundWorker3, 100);
        }

        private void uiTextBox69_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2256", this.backgroundWorker3, 100);
        }

        private void uiTextBox68_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2258", this.backgroundWorker3, 100);
        }

        private void uiTextBox67_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2260", this.backgroundWorker3, 100);
        }

        private void uiTextBox66_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2262", this.backgroundWorker3, 100);
        }

        private void uiTextBox65_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2264", this.backgroundWorker3, 100);
        }

        private void uiTextBox64_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2266", this.backgroundWorker3, 100);
        }

        private void uiTextBox59_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2030", this.backgroundWorker3);
        }

        private void uiTextBox58_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2272", this.backgroundWorker3);
        }

        private void uiTextBox74_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2020", this.backgroundWorker3);
        }

        private void uiTextBox73_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2024", this.backgroundWorker3);
        }

        private void uiTextBox72_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2042", this.backgroundWorker3);
        }

        private void uiTextBox60_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2022", this.backgroundWorker3);
        }

        private void uiTextBox57_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2026", this.backgroundWorker3);
        }

        private void uiTextBox61_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2040", this.backgroundWorker3);
        }

        private void uiTextBox85_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2066", this.backgroundWorker3);
        }

        private void uiTextBox84_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2070", this.backgroundWorker3);
        }

        private void uiTextBox83_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2074", this.backgroundWorker3);
        }

        private void uiTextBox82_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2078", this.backgroundWorker3);
        }

        private void uiTextBox81_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2082", this.backgroundWorker3);
        }

        private void uiTextBox80_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2086", this.backgroundWorker3);
        }

        private void uiTextBox79_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2118", this.backgroundWorker3);
        }

        private void uiTextBox78_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2122", this.backgroundWorker3);
        }

        private void uiTextBox77_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2090", this.backgroundWorker3);
        }

        private void uiTextBox71_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2068", this.backgroundWorker3);
        }

        private void uiTextBox63_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2072", this.backgroundWorker3);
        }

        private void uiTextBox86_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2076", this.backgroundWorker3);
        }

        private void uiTextBox62_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2080", this.backgroundWorker3);
        }

        private void uiTextBox87_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2084", this.backgroundWorker3);
        }

        private void uiTextBox88_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2088", this.backgroundWorker3);
        }

        private void uiTextBox75_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2120", this.backgroundWorker3);
        }

        private void uiTextBox76_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2124", this.backgroundWorker3);
        }

        private void uiTextBox89_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2092", this.backgroundWorker3);
        }

        private void uiTextBox134_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2224", this.backgroundWorker3);
        }

        private void uiTextBox133_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2228", this.backgroundWorker3);
        }

        private void uiTextBox132_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2232", this.backgroundWorker3);
        }

        private void uiTextBox131_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2236", this.backgroundWorker3);
        }

        private void uiTextBox123_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2238", this.backgroundWorker3);
        }

        private void uiTextBox122_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2244", this.backgroundWorker3);
        }

        private void uiTextBox121_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2248", this.backgroundWorker3);
        }

        private void uiTextBox118_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2286", this.backgroundWorker3);
        }

        private void uiTextBox114_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2226", this.backgroundWorker3);
        }

        private void uiTextBox113_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2230", this.backgroundWorker3);
        }

        private void uiTextBox139_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2234", this.backgroundWorker3);
        }

        private void uiTextBox112_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2242", this.backgroundWorker3);
        }

        private void uiTextBox140_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2240", this.backgroundWorker3);
        }

        private void uiTextBox141_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2246", this.backgroundWorker3);
        }

        private void uiTextBox111_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2250", this.backgroundWorker3);
        }

        private void uiTextBox146_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2054", this.backgroundWorker3);
        }

        private void uiTextBox145_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2056", this.backgroundWorker3);
        }

        private void uiTextBox144_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2058", this.backgroundWorker3);
        }

        private void uiTextBox143_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2310", this.backgroundWorker3);
        }

        private void uiTextBox110_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2110", this.backgroundWorker3);
        }

        private void uiTextBox109_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2108", this.backgroundWorker3);
        }

        private void uiTextBox147_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2060", this.backgroundWorker3);
        }

        private void uiTextBox108_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2034", this.backgroundWorker3);
        }

        private void uiTextBox149_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2188", this.backgroundWorker3);
        }

        private void uiTextBox148_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2190", this.backgroundWorker3);
        }

        private void uiTextBox142_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2192", this.backgroundWorker3);
        }

        private void uiTextBox117_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteUInt32((UITextBox)sender, "D2200", this.backgroundWorker3);
        }

        private void uiTextBox116_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2194", this.backgroundWorker3);
        }

        private void uiTextBox115_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2198", this.backgroundWorker3);
        }

        private void uiTextBox150_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2196", this.backgroundWorker3);
        }

        private void uiTextBox107_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2034", this.backgroundWorker3);
        }

        private void uiTextBox157_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2132", this.backgroundWorker3);
        }

        private void uiTextBox156_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2136", this.backgroundWorker3);
        }

        private void uiTextBox155_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2140", this.backgroundWorker3);
        }

        private void uiTextBox154_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2144", this.backgroundWorker3);
        }

        private void uiTextBox163_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2148", this.backgroundWorker3);
        }

        private void uiTextBox164_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2152", this.backgroundWorker3);
        }

        private void uiTextBox165_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2156", this.backgroundWorker3);
        }

        private void uiTextBox166_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2160", this.backgroundWorker3);
        }

        private void uiTextBox167_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2164", this.backgroundWorker3);
        }

        private void uiTextBox153_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2134", this.backgroundWorker3);
        }

        private void uiTextBox152_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2138", this.backgroundWorker3);
        }

        private void uiTextBox151_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2142", this.backgroundWorker3);
        }

        private void uiTextBox158_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2146", this.backgroundWorker3);
        }

        private void uiTextBox168_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2150", this.backgroundWorker3);
        }

        private void uiTextBox169_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2154", this.backgroundWorker3);
        }

        private void uiTextBox170_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2158", this.backgroundWorker3);
        }

        private void uiTextBox171_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2162", this.backgroundWorker3);
        }

        private void uiTextBox172_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2164", this.backgroundWorker3);
        }

        private void uiTextBox159_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2170", this.backgroundWorker3);
        }

        private void uiTextBox160_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2172", this.backgroundWorker3);
        }

        private void uiTextBox161_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2174", this.backgroundWorker3);
        }

        private void uiTextBox162_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2176", this.backgroundWorker3);
        }

        private void uiTextBox173_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2178", this.backgroundWorker3);
        }

        private void uiTextBox174_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2180", this.backgroundWorker3);
        }

        private void uiTextBox175_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2182", this.backgroundWorker3);
        }

        private void uiTextBox176_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2184", this.backgroundWorker3);
        }

        private void uiTextBox177_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingle((UITextBox)sender, "D2186", this.backgroundWorker3);
        }

        private void uiTextBox185_Enter(object sender, EventArgs e)
        {
            gButtonFlag = ControlAttribute.TextBoxWriteSingleToUInt32((UITextBox)sender, "D2328", this.backgroundWorker3, 100);
        }
        private void toolStripMenuItemBlue_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Blue;
                Settings.Default.UIStyle = UIStyle.Blue;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemGreen_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Green;
                Settings.Default.UIStyle = UIStyle.Green;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemOrange_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Orange;
                Settings.Default.UIStyle = UIStyle.Orange;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemRed_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Red;
                Settings.Default.UIStyle = UIStyle.Red;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemGray_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Gray;
                Settings.Default.UIStyle = UIStyle.Gray;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemPurple_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Purple;
                Settings.Default.UIStyle = UIStyle.Purple;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemLayuiGreen_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.LayuiGreen;
                Settings.Default.UIStyle = UIStyle.LayuiGreen;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemLayuiRed_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.LayuiRed;
                Settings.Default.UIStyle = UIStyle.LayuiRed;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemLayuiOrange_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.LayuiOrange;
                Settings.Default.UIStyle = UIStyle.LayuiOrange;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemDarkBlue_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.DarkBlue;
                Settings.Default.UIStyle = UIStyle.DarkBlue;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemBlack_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Black;
                Settings.Default.UIStyle = UIStyle.Black;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemColorful_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Colorful;
                Settings.Default.UIStyle = UIStyle.Colorful;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemCustom_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                uiStyleManager1.Style = UIStyle.Custom;
                Settings.Default.UIStyle = UIStyle.Custom;
                Settings.Default.Save();//使用Save方法保存更改
            };
            Invoke(action);
        }

        private void toolStripMenuItemRandom_Click(object sender, EventArgs e)
        {
            Action action = () =>
            {
                UIStyles.InitColorful(RandomColor.GetColor(ColorScheme.Random, Luminosity.Bright), Color.White);
            };
            Invoke(action);
        }

        private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs args)
        {
            OpenGL gl = this.openGLControl1.OpenGL;
            //清除深度缓存 
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            //重置当前指定的矩阵为单位矩阵,将当前的用户坐标系的原点移到了屏幕中心
            gl.LoadIdentity();

            //gl.Viewport(0, 0, Width, Height);设置坐标，该函数有四个参数，分别为视口左下角的x和y坐标以及视口的宽度和高度。
            //坐标轴变换位置到(0.0f, 0.0f, -5.0f)，这样我们的坐标轴就相当于往屏幕内走5个单位
            gl.Translate(-1.0f, -1.0f, 0.0f);

            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******实际比例阀开度******
            gl.Color(1.0f, 0.0f, 1.0f);//(255,0,255)
            for (int i = 0; i < arrSource.GetLength(0); i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((arrSource.GetLength(0) - i - 1)) / Convert.ToSingle(arrSource.GetLength(0) - 1), arrSource[i, 5]/100.0, 0.0f);//实际比例阀开度(0~100%)
            }
            gl.End();

            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******PID输出开度******
            gl.Color(1.0f, 1.0f, 0.0f);//(255,255,0)
            for (int i = 0; i < arrSource.GetLength(0); i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((arrSource.GetLength(0) - i - 1)) / Convert.ToSingle(arrSource.GetLength(0) - 1), arrSource[i, 4]/100.0, 0.0f);//PID输出开度(0~100%)
            }
            gl.End();

            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******实际温度******
            gl.Color(1.0f, 0.0f, 0.0f);//(255,0,0)
            for (int i = 0; i < arrSource.GetLength(0); i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((arrSource.GetLength(0) - i - 1)) / Convert.ToSingle(arrSource.GetLength(0) - 1), (arrSource[i, 3] - 75.0) / 50.0 + 1.0f, 0.0f);//实际温度(75~125℃)
            }
            gl.End();

            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******设定温度******
            gl.Color(0.313725f, 0.627451f, 1.0f);//(128,128,255)
            for (int i = 0; i < arrSource.GetLength(0); i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((arrSource.GetLength(0) - i - 1)) / Convert.ToSingle(arrSource.GetLength(0) - 1), (arrSource[i, 2] - 75.0) / 50.0 + 1.0f, 0.0f);//设定温度(75~125℃)
            }
            gl.End();

            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******实际压力******
            gl.Color(0.0f, 0.784313f, 0.0f);//(0,200,0)
            for (int i = 0; i < arrSource.GetLength(0); i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((arrSource.GetLength(0) - i - 1)) / Convert.ToSingle(arrSource.GetLength(0) - 1), 2.0 * arrSource[i, 1], 0.0f);//实际压力(0~0.5bar)
            }
            gl.End();

            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******设定压力******
            gl.Color(1.0f, 1.0f, 1.0f);//(255,255,255)
            for (int i = 0; i < arrSource.GetLength(0); i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((arrSource.GetLength(0) - i - 1)) / Convert.ToSingle(arrSource.GetLength(0) - 1), 2.0 * arrSource[i, 0], 0.0f);//设置压力(0~0.5bar)
            }
            gl.End();

            gl.Flush();   //强制刷新
        }

        private void openGLControl1_OpenGLInitialized(object sender, EventArgs e)
        {
            OpenGL gl = openGLControl1.OpenGL;
            //曲线背景色
            gl.ClearColor(0.219607f, 0.219607f, 0.219607f, 0.0f);

        }

        private void openGLControl1_Resized(object sender, EventArgs e)
        {
            Console.WriteLine("openGLControl1_Resized");
        }

        private void openGLControl2_OpenGLDraw(object sender, RenderEventArgs args)
        {
            OpenGL gl = this.openGLControl2.OpenGL;
            //清除深度缓存 
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            //重置当前指定的矩阵为单位矩阵,将当前的用户坐标系的原点移到了屏幕中心
            gl.LoadIdentity();

            //gl.Viewport(0, 0, Width, Height);设置坐标，该函数有四个参数，分别为视口左下角的x和y坐标以及视口的宽度和高度。
            //坐标轴变换位置到(0.0f, 0.0f, -5.0f)，这样我们的坐标轴就相当于往屏幕内走5个单位
            gl.Translate(-1.0f, -1.0f, 0.0f);
            
            gl.Begin(OpenGL.GL_LINE_STRIP);
            //******实际密度******
            gl.Color(1.0f, 1.0f, 1.0f);
            for (int i = 0; i < dwsSource.Length; i++)
            {
                gl.Vertex(2.0 * Convert.ToSingle((dwsSource.Length - i - 1)) / Convert.ToSingle(dwsSource.Length - 1), dwsSource[i] - Global.rData.D1068 + 1.0f, 0.0f);//实际密度
            }
            gl.End();
            
            gl.Flush();   //强制刷新
        }

        private void openGLControl2_OpenGLInitialized(object sender, EventArgs e)
        {
            OpenGL gl = openGLControl2.OpenGL;
            //曲线背景色
            gl.ClearColor(0.219607f, 0.219607f, 0.219607f, 0.0f);
        }

        private void openGLControl2_Resized(object sender, EventArgs e)
        {
            Console.WriteLine("openGLControl2_Resized");
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            //打开授权窗口
            if (Global.IsLogin == 3)//连接产能授权通道
            {
                FLocker frm = new FLocker
                {
                    Style = Settings.Default.UIStyle
                };
                frm.ShowDialog();
                frm.Dispose();
            }
            else
            {
                if (Settings.Default.Language == 0)  // 中文
                {
                    ShowErrorTip("未经授权!");
                }
                else if (Settings.Default.Language == 1) // 英文
                {
                    ShowErrorTip("Unauthorized!");
                }
            }
        }

        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            bool v = false;
            if (Settings.Default.Language == 0)  // 中文
            {
                v = UIMessageDialog.ShowMessageDialog("计算机关机?", UILocalize.WarningTitle, true, UIStyle.Orange);
            }
            else if (Settings.Default.Language == 1) // 英文
            {
                v = UIMessageDialog.ShowMessageDialog("Computer shutdown?", UILocalize.WarningTitle, true, UIStyle.Orange);
            }
            if (v == true)
            {
                HslMelsecMCBinary.WriteBool("M2002", false);//关闭自动功能
                HslMelsecMCBinary.WriteBool("M2001", false);//关闭上料功能
                Process.Start("shutdown.exe", "-s -t 1");//关机电脑
                Environment.Exit(0);//关闭程序
            }
        }

        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {
            //打开登录窗口
            FHelpQRCode frm = new FHelpQRCode
            {
                Style = Settings.Default.UIStyle
            };
            frm.ShowDialog();
            frm.Dispose();
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            //打开授权窗口
            if (Global.IsLogin == 2)//连接授权通道
            {
                FLicense frm = new FLicense
                {
                    Style = Settings.Default.UIStyle
                };
                frm.ShowDialog();
                frm.Dispose();
            }
            else
            {
                //double latitude, longitude;
                Global.getCurrentPosition(out double latitude, out double longitude);
                UIMessageDialog.ShowMessageDialog("PN:" + original + "\r\n" + "License:" + ActivationStatus + "\r\n" + "Position:" + latitude.ToString() + "," + longitude.ToString(), UILocalize.InfoTitle, false, Style);
            }
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            //打开登录窗口
            FLogin frm = new FLogin
            {
                Style = Settings.Default.UIStyle
            };
            frm.ShowDialog();
            frm.Dispose();
        }

    }
}
